In: Statistics and Probability
R studio.
The file I read contains the lower and upper bound of 10,000 98% confidence intervals for a population mean. All intervals are constructed from samples of size 30 from the same population.
As a comment, how many of the 10,000 intervals do we expect to contain the true population mean?
Use if else function to determine if the true population mean of 50 is contained in each interval. If an interval contains the true population mean , then record a 1. otherwise, record 0. use another simple function to count the number of intervals that actually contain the true population mean.
LB UB 1 48.82272 51.30366 2 47.85011 50.75911 3 48.39593 50.86317 4 49.50380 51.82882 5 48.56808 51.10763 6 48.33720 51.15795 7 49.58479 52.30173 8 48.06352 50.64677 9 46.97609 49.91360 10 48.23880 50.92644 11 48.20511 51.27409 12 48.94604 51.21771 13 49.14323 52.10076 14 48.34674 50.72505 15 47.99025 51.17251 16 49.31222 52.24073 17 48.42335 50.85923 18 48.55645 51.30947 19 48.66502 50.89891 20 48.31210 51.02289 21 48.65195 51.29623 22 48.57981 51.35273 23 49.28317 51.80582 24 48.53978 51.50162 25 48.68356 51.59459 26 48.60266 50.80870 27 48.53445 51.66937 28 48.72546 51.39291 29 47.44066 50.02556 30 48.52205 51.17847 31 48.73524 51.25268 32 48.50100 50.80092 33 48.38974 51.32582 34 49.23366 52.03479 35 48.73807 51.57349 36 48.83860 50.91037 37 48.59342 51.48773 38 49.03301 50.72731 39 48.78176 51.50024 40 48.26298 50.92905 41 48.65888 51.77052 42 48.43509 50.55117 43 49.67746 51.93227 44 48.93457 51.67466 45 47.97452 50.60386 46 48.43416 50.94204 47 48.46911 51.29342 48 47.99619 51.16726 49 48.54371 51.22938 50 47.76050 50.69209 51 48.01145 50.30868 52 47.70307 50.69561 53 49.16509 52.34635 54 49.42015 52.14595 55 48.25789 50.99127 56 48.40341 51.27524 57 49.01722 51.93094 58 49.96117 52.26430 59 48.16817 51.05651 60 49.17935 51.74603 61 48.89957 51.92129 62 48.10730 50.28900 63 48.59000 52.22029 64 48.53050 51.10354 65 48.45223 50.88710 66 49.21200 51.57518 67 48.55665 51.44040 68 48.95475 51.55773 69 48.94291 51.38004 70 47.90089 50.99178 71 48.50173 50.94314 72 48.45513 51.11692 73 47.90871 50.89449 74 47.70506 51.22094 75 48.33921 50.64114 76 50.02632 52.15664 77 48.09500 50.58005 78 48.88905 51.30580 79 48.46436 50.98724 80 47.85269 50.48144 81 47.65872 51.12160 82 48.89871 51.30326 83 48.75556 50.76731 84 48.78316 51.05772 85 48.55003 51.01114 86 47.71575 50.52735 87 49.37902 51.87349 88 47.87913 50.74057 89 48.23371 51.17239 90 48.06149 50.39318 91 48.93308 51.46548 92 49.21280 51.71634 93 48.59412 51.39782 94 49.67277 51.84224 95 49.28704 52.08790 96 48.72638 51.70117 97 48.31556 50.61340 98 48.61119 51.68274 99 49.18080 51.53544 100 47.61227 50.16820 101 48.82926 51.20851 102 48.31915 51.27786 103 48.14510 51.61156 104 48.43267 50.78132 105 48.28254 51.32600 106 48.39814 51.30264 107 47.95319 50.62435 108 49.83925 52.51739 109 48.35944 51.01766 110 48.57429 51.38465 111 48.55923 51.07643 112 48.95902 50.99336 113 47.95920 50.80227 114 48.60200 51.73162 115 48.09973 50.74910 116 48.85072 51.05844 117 48.78941 51.81272 118 47.94201 50.71102 119 48.51234 51.15113 120 48.67375 51.63517 121 48.64139 51.68602 122 47.75612 50.46703 123 48.67059 51.42052 124 48.09576 51.07715 125 49.37720 52.23383 126 49.43083 52.08122 127 48.50562 51.39762 128 48.99931 51.33532 129 47.63214 50.55941 130 48.52189 51.22927 131 48.29439 50.69421 132 49.30644 51.87455 133 47.42131 50.25915 134 49.16207 51.60797 135 50.01296 52.94989 136 49.10513 51.46615 137 48.77741 50.80060 138 48.24382 50.86109 139 47.68605 51.39100 140 48.53876 51.30355 141 49.11038 51.43809 142 48.92087 52.21191 143 48.40823 51.00876 144 48.35416 50.78246 145 49.00370 51.59688 146 48.83742 51.30304 147 49.38288 51.54634 148 48.52638 50.89307 149 48.43147 50.96575 150 49.51156 52.45901 151 48.30947 50.75264 152 48.65666 52.06264 153 47.53873 50.62694 154 48.97277 51.59316 155 47.89711 50.74558 156 48.59672 51.03416 157 49.01263 51.49236 158 49.54921 51.65144 159 47.83151 50.55320 160 49.31743 52.20174 161 49.42357 51.98323 162 49.03040 51.46993 163 48.04456 50.76240 164 48.75804 52.12364 165 47.64634 50.50156 166 48.80462 52.17708 167 48.83134 51.48767 168 48.21504 50.97351 169 48.81646 52.00578 170 48.15212 51.04534 171 49.72071 52.74574 172 48.65917 51.59945 173 48.34740 50.68027 174 49.42349 51.82766 175 47.76089 50.64166 176 49.44961 51.52234 177 49.12248 51.00450 178 48.25620 51.53334 179 48.79215 51.33376 180 49.41500 52.14297 181 48.17524 50.47328 182 48.66058 51.90062 183 48.20894 50.83547 184 48.64847 51.87457 185 49.15202 51.35655 186 48.45635 51.58770 187 48.21649 50.78333 188 48.13771 51.19793 189 48.41331 50.74956 190 50.03155 52.35838 191 49.58294 52.14418 192 47.25417 50.11865 193 48.84927 51.52156 194 48.88043 51.67025 195 47.99342 50.35937 196 48.86192 51.29783 197 47.45850 50.18512 198 49.59162 52.47297 199 48.87785 51.32875 200 47.90418 50.04092 201 49.83806 52.19935 202 47.69015 50.71301 203 48.09299 51.35362 204 49.17409 51.45369 205 48.80720 51.51675 206 49.45134 51.58023 207 48.44732 51.60204 208 48.51654 51.54519 209 48.94422 51.30512 210 49.58301 51.93820 211 47.97123 49.95980 212 47.47083 50.26808 213 47.80895 50.71045 214 48.64762 51.39270 215 49.02379 51.34965 216 48.41929 51.11002 217 48.44066 50.80170 218 49.00728 51.26125 219 48.33492 51.43666 220 49.52027 52.13383 221 48.85290 51.36695 222 49.23361 51.54561 223 49.17813 51.56875 224 48.41697 51.64245 225 47.88436 50.67827 226 48.93780 52.23120 227 49.55336 51.98197 228 48.29684 50.64537 229 48.98134 51.38557 230 48.20767 51.55897 231 49.25277 51.68138 232 47.96149 50.68632 233 48.96494 51.31722 234 48.86132 51.88765 235 48.26054 50.58916 236 48.59627 50.83939 237 48.26988 50.75478 238 48.47282 50.73504 239 48.88159 51.50583 240 49.20482 51.38266 241 49.50121 51.87642 242 49.10054 51.39124 243 48.92478 51.41669 244 48.26964 51.10945 245 48.43229 51.38427 246 48.16820 50.87966 247 48.38549 51.67114 248 49.23977 51.78047 249 49.64792 52.02347 250 49.04561 52.43617 251 48.98915 51.96953 252 48.77861 51.72435 253 49.34512 52.20400 254 48.77097 51.04397 255 48.44165 51.04354 256 48.01325 51.40037 257 48.82503 51.87068 258 49.02115 51.62762 259 48.30087 50.99395 260 48.10411 50.73797 261 48.82529 51.58163 262 49.01528 51.79095 263 48.79496 51.47613 264 47.96925 51.12558 265 49.62587 52.30828 266 49.22415 50.97231 267 49.38396 51.13713 268 48.51912 50.64159 269 48.33830 50.10063 270 49.38432 52.25062 271 48.34578 51.08557 272 49.23433 51.62159 273 49.28289 51.40681 274 49.17267 51.53598 275 48.56442 51.36944 276 48.28537 51.14154 277 48.81525 51.64292 278 48.42813 50.64870 279 49.24045 52.49323 280 48.62801 51.17991 281 47.94672 51.14264 282 48.30132 51.06298 283 50.05754 51.89577 284 49.37244 52.31054 285 48.35175 50.25944 286 47.95359 50.54685 287 48.63321 51.32578 288 48.84791 51.40400 289 49.06524 51.22998 290 48.82153 51.12875 291 49.31704 51.66836 292 48.85663 51.32540 293 48.20009 50.69489 294 48.16190 51.17043 295 49.55253 52.43455 296 48.69902 51.39729 297 48.82556 51.57249 298 48.76276 51.17254 299 48.86948 51.28091 300 48.72766 51.21970 301 48.44610 51.11079 302 48.00021 50.15543 303 49.42880 51.87595 304 48.58219 50.68780 305 50.07464 52.52340 306 48.31237 50.82119 307 49.23674 52.15685 308 49.42942 52.33765 309 48.11667 51.25361 310 47.84972 50.15164 311 47.44239 50.09728 312 48.35219 50.85891 313 49.33312 52.02076 314 48.06922 51.28937 315 48.93060 51.09046 316 47.83314 50.86894 317 48.09463 50.47688 318 47.91868 51.02247 319 48.73552 51.46030 320 49.04664 52.14535 321 48.97470 51.59980 322 48.80350 51.50556 323 48.08633 50.98626 324 48.76969 51.54197 325 48.20972 50.91649 326 48.87603 51.61202 327 48.05395 51.02859 328 48.90004 51.40396 329 48.08102 50.98926 330 48.92682 51.26975 331 48.07960 50.98550 332 48.45479 50.91147 333 49.30655 51.16616 334 49.57019 51.62665 335 49.59756 52.21105 336 49.27978 52.07583 337 49.02587 51.67876 338 49.05640 51.75095 339 49.41067 51.64558 340 47.71828 50.16604 341 47.88478 50.46554 342 49.37218 51.41576 343 47.60982 50.60973 344 48.81343 51.39902 345 48.34318 50.66721 346 48.58661 51.27513 347 48.74877 50.99491 348 48.41430 51.36293 349 49.01001 51.39993 350 49.06977 51.38908 351 49.15311 51.89894 352 48.29487 51.09689 353 48.86584 51.11819 354 49.89577 52.54236 355 48.91982 51.93447 356 48.59579 51.03624 357 49.29968 52.15329 358 49.12660 51.95624 359 48.38123 51.11630 360 49.04480 51.38700 361 48.50068 51.26122 362 48.16140 50.89996 363 48.86531 51.00114 364 47.00044 49.50477 365 49.06123 52.79876 366 48.81461 51.06214 367 49.59537 52.40065 368 48.41697 51.15690 369 49.56054 52.75075 370 48.05078 50.22665 371 49.29852 51.89714 372 47.35272 50.38037 373 47.86439 50.97649 374 48.27598 51.42949 375 49.23040 51.85370 376 48.11987 51.59977 377 47.89244 50.06745 378 48.92912 51.78426 379 47.90229 50.70529 380 48.79054 51.41679 381 48.70002 51.72568 382 49.18605 51.83708 383 48.95085 51.36403 384 49.24485 52.40337 385 48.19895 50.55362 386 48.52274 50.98295 387 48.35110 51.04053 388 48.78496 51.74919 389 48.60546 51.53101 390 48.79854 51.38634 391 48.66749 51.69851 392 47.79454 51.13213 393 49.22741 51.64429 394 48.13613 50.35030 395 48.76199 51.20824 396 48.17696 50.29663 397 48.99561 51.43026 398 49.38308 51.84759 399 48.15648 50.93732 400 48.02939 51.03028 401 48.57095 51.66393 402 48.67521 51.14010 403 47.85850 50.81717 404 49.27910 51.96977 405 49.00061 51.89358 406 48.97423 52.04610 407 49.27063 51.47028 408 48.69118 51.36288 409 48.71507 51.30883 410 48.13450 51.29541 411 48.85440 51.23987 412 48.52115 50.61469 413 48.55738 51.10016 414 48.78731 50.97615 415 49.01520 51.40252 416 48.25358 50.38346 417 48.18268 50.83626 418 48.59212 51.70159 419 47.51140 50.77303 420 47.31718 50.58834 421 48.82820 52.08861 422 48.24191 51.19371 423 48.38576 51.04301 424 48.59165 50.95777 425 48.58854 51.46934 426 48.04972 50.96441 427 48.25358 50.98370 428 48.97992 51.93969 429 48.76633 51.48820 430 48.72649 51.60702 431 48.26235 50.81540 432 48.73850 51.28282 433 48.01231 50.81824 434 48.50689 51.18325 435 48.41178 51.23206 436 48.52354 51.16599 437 49.11342 51.65564 438 49.68061 52.14200 439 48.32455 50.25582 440 48.85609 51.27603 441 49.14751 51.74516 442 48.47412 50.92351 443 48.71494 51.17900 444 48.00950 50.64196 445 49.20432 51.32977 446 49.24168 51.61824 447 48.35331 51.30285 448 49.05033 51.33215 449 48.76081 50.83013 450 48.72853 51.40939 451 49.40518 52.01238 452 49.38355 52.07482 453 49.36536 51.46615 454 48.61344 51.64655 455 48.55320 50.87193 456 49.54888 52.55029 457 48.79097 51.02604 458 47.06805 50.27794 459 48.12485 50.41138 460 48.61695 51.19227 461 48.13602 51.00126 462 48.82556 51.34675 463 49.05779 51.92811 464 49.57418 51.75850 465 48.09423 50.61218 466 48.02291 50.43108 467 48.40567 50.98923 468 48.55689 51.39618 469 49.01564 51.12879 470 48.91510 51.61181 471 48.73073 51.57080 472 48.53983 51.37197 473 48.63880 51.43618 474 49.28973 51.74833 475 48.44200 51.20024 476 49.31388 51.64599 477 48.72383 51.40989 478 49.14558 51.62147 479 48.14565 50.89550 480 49.44831 52.32590 481 47.95923 50.63820 482 48.44001 50.97196 483 49.35966 52.04062 484 48.60488 51.55164 485 49.04828 51.31570 486 48.45293 50.90125 487 49.03894 51.81015 488 49.67828 52.66242 489 48.69551 51.71400 490 48.53864 51.40861 491 48.72995 51.34008 492 48.61452 51.02528 493 48.20427 50.95025 494 48.53882 51.74698 495 48.81162 51.62866 496 48.44266 51.29633 497 49.72625 52.37027 498 48.61004 51.04595 499 49.20746 51.71339 500 48.10826 51.22831 [ reached getOption("max.print") -- omitted 9500 rows ] |
|
|
We expect 98% of the 10,000 intervals to contain the true population mean.
Using Rstudio
data<-read.csv("Confidence_Interval.csv",sep="\t")
head(data)
data$Truth<-ifelse(data$LB<50 & data$UB>50 ,1,0)
table(data$Truth)