Ejercicio # 1 #Se obtuvieron durante 132 días las concentraciones máximas de ozono (en partes por \(10^9\)) en una determinada zona de Nueva York. Estados Unidos fija como requirimiento un nivel máximo de 120 de ozono. De los 132 días, 2 días presentaron niveles de ozono por encima de 120. Contrasta si la proporción de días con nivel de ozono mayor que el permitido es menor o igual que 0.05 y calcula un intervalo de confianza al 95\(\%\).
binom.test(2,132,p=0.05, alternative = "l", conf.level = 0.95)
##
## Exact binomial test
##
## data: 2 and 132
## number of successes = 2, number of trials = 132, p-value = 0.03658
## alternative hypothesis: true probability of success is less than 0.05
## 95 percent confidence interval:
## 0.00000000 0.04692521
## sample estimates:
## probability of success
## 0.01515152
HO:media de Month0 igual a 10 H1: media de Month0 es diferente a 10
df <- read.table("medicamentos-1.csv", header = T, sep = ";")
df
## ID Sex Group Month0 Month3 Month6
## 1 1 F P 12.741917 10.302912 8.302369
## 2 2 F P 8.870604 8.831782 7.822960
## 3 3 F P 10.726257 10.737613 9.031419
## 4 4 F P 11.265725 10.589309 9.327378
## 5 5 F P 10.808537 9.441481 9.693284
## 6 6 F P 9.787751 7.327527 9.513506
## 7 7 F P 13.023044 11.401498 13.784404
## 8 8 F P 9.810682 11.108393 7.228003
## 9 9 F P 14.036847 8.327387 9.170351
## 10 10 F P 9.874572 6.810824 10.698163
## 11 11 F P 12.609739 10.409917 13.256885
## 12 12 F P 14.573291 9.309824 10.177044
## 13 13 F P 7.222279 10.505223 12.478301
## 14 14 F P 9.442422 7.411995 6.710889
## 15 15 F P 9.733357 8.081659 12.892713
## 16 16 F P 11.271901 12.171550 8.618880
## 17 17 F P 9.431494 10.807550 9.447138
## 18 18 F P 4.687089 11.172975 7.781162
## 19 19 F P 5.119066 13.630457 10.267739
## 20 20 F P 12.640227 10.257643 13.570678
## 21 21 F P 9.386723 5.998142 14.844327
## 22 22 F P 6.437383 10.667554 7.846342
## 23 23 F P 9.656165 12.342650 10.971882
## 24 24 F P 12.429349 14.119078 12.777043
## 25 31 M P 10.910900 7.597556 10.640376
## 26 32 M P 11.409675 14.073944 9.396260
## 27 33 M P 12.070207 10.215549 10.996697
## 28 34 M P 8.782147 9.831784 8.900926
## 29 35 M P 11.009910 10.991239 9.441487
## 30 36 M P 6.565983 10.074830 12.193027
## 31 37 M P 8.431082 9.735824 10.884026
## 32 38 M P 8.298185 12.953575 10.482033
## 33 39 M P 5.171585 9.565940 9.488785
## 34 40 M P 10.072245 7.432796 11.862066
## 35 41 M P 10.411997 10.771336 12.669825
## 36 42 M P 9.277885 9.296974 8.261456
## 37 43 M P 11.516326 8.956408 10.110974
## 38 44 M P 8.546590 7.863738 10.098134
## 39 45 M P 7.263438 10.856732 8.843289
## 40 46 M P 10.865636 9.651964 8.002523
## 41 47 M P 8.377214 11.031335 9.995134
## 42 48 M P 12.888203 9.531269 11.311024
## 43 49 M P 9.137108 8.682993 12.953685
## 44 50 M P 11.311296 12.500473 6.181694
## 45 51 M P 10.643851 9.456473 8.595121
## 46 52 M P 8.432322 11.895904 9.377140
## 47 53 M P 13.151455 7.596835 6.673686
## 48 54 M P 11.285799 9.067768 8.498933
## 49 61 F M1 9.265531 4.541565 9.591912
## 50 62 F M1 10.370461 7.996138 5.092941
## 51 63 F M1 11.163647 8.516963 8.196791
## 52 64 F M1 12.799474 8.497727 6.812458
## 53 65 F M1 8.545416 3.238726 9.776562
## 54 66 F M1 12.605085 10.099921 8.106141
## 55 67 F M1 10.671696 8.033746 6.885953
## 56 68 F M1 12.077012 5.946565 8.876794
## 57 69 F M1 11.841457 7.407216 8.305216
## 58 70 F M1 11.441756 4.057230 7.670765
## 59 71 F M1 7.913762 3.807688 12.039781
## 60 72 F M1 9.819627 6.098101 6.941228
## 61 73 F M1 11.247036 3.603008 7.058426
## 62 74 F M1 8.092953 6.380038 4.908126
## 63 75 F M1 8.914342 8.595412 7.918947
## 64 76 F M1 11.161993 3.932253 9.780713
## 65 77 F M1 11.536357 4.523118 3.857224
## 66 78 F M1 10.927535 6.093128 7.499870
## 67 79 F M1 8.228447 3.964808 5.636699
## 68 80 F M1 7.800438 5.233432 10.883875
## 69 81 F M1 13.025414 7.745511 10.715791
## 70 82 F M1 10.515843 7.939090 8.669006
## 71 83 F M1 10.176880 6.767693 10.858676
## 72 84 F M1 9.758207 2.296889 6.265364
## 73 91 M M1 12.784233 7.147503 5.392358
## 74 92 M M1 9.047652 6.091607 7.498171
## 75 93 M M1 11.300697 6.314825 8.342015
## 76 94 M M1 12.782221 6.863131 7.193065
## 77 95 M M1 7.778422 5.206901 8.209319
## 78 96 M M1 8.278415 8.619956 7.362238
## 79 97 M M1 7.736523 6.940787 11.236688
## 80 98 M M1 7.081572 3.514659 9.428377
## 81 99 M M1 10.159965 8.763151 13.931731
## 82 100 M M1 11.306409 8.408918 6.409845
## 83 101 M M1 12.401931 7.648148 9.628732
## 84 102 M M1 12.089502 2.674741 12.196062
## 85 103 M M1 7.993583 4.861387 8.601960
## 86 104 M M1 13.696964 7.271028 5.833850
## 87 105 M M1 8.666453 6.087444 5.987355
## 88 106 M M1 10.211028 6.696025 7.929171
## 89 107 M M1 9.155488 10.919187 10.618249
## 90 108 M M1 9.755300 4.363239 9.500801
## 91 109 M M1 10.376386 1.773600 3.723263
## 92 110 M M1 10.238322 6.547391 6.599292
## 93 111 M M1 9.949815 4.624806 7.981887
## 94 112 M M1 10.216145 6.892082 5.083733
## 95 113 M M1 9.029130 4.375231 9.389059
## 96 114 M M1 8.991566 10.424111 3.077329
head(df)
## ID Sex Group Month0 Month3 Month6
## 1 1 F P 12.741917 10.302912 8.302369
## 2 2 F P 8.870604 8.831782 7.822960
## 3 3 F P 10.726257 10.737613 9.031419
## 4 4 F P 11.265725 10.589309 9.327378
## 5 5 F P 10.808537 9.441481 9.693284
## 6 6 F P 9.787751 7.327527 9.513506
summary(df)
## ID Sex Group Month0 Month3
## Min. : 1.00 F:48 M1:48 Min. : 4.687 Min. : 1.774
## 1st Qu.: 29.25 M:48 P :48 1st Qu.: 8.848 1st Qu.: 6.261
## Median : 57.50 Median :10.194 Median : 8.205
## Mean : 57.50 Mean :10.129 Mean : 8.122
## 3rd Qu.: 85.75 3rd Qu.:11.336 3rd Qu.:10.269
## Max. :114.00 Max. :14.573 Max. :14.119
## Month6
## Min. : 3.077
## 1st Qu.: 7.499
## Median : 8.966
## Mean : 9.016
## 3rd Qu.:10.624
## Max. :14.844
qqnorm( df$Month0 )
qqline( df$Month0 )
ks.test (df$Month0, "pnorm")
##
## One-sample Kolmogorov-Smirnov test
##
## data: df$Month0
## D = 1, p-value = 1.332e-15
## alternative hypothesis: two-sided
length(df$Month0)
## [1] 96
t.test(df$Month0, mu = 10, alternative = "t")
##
## One Sample t-test
##
## data: df$Month0
## t = 0.63124, df = 95, p-value = 0.5294
## alternative hypothesis: true mean is not equal to 10
## 95 percent confidence interval:
## 9.724152 10.533047
## sample estimates:
## mean of x
## 10.1286
qqnorm( df$Month0[ df$Sex == "M" ] )
qqline( df$Month0[ df$Sex == "M" ] )
ks.test (df$Month0[df$Sex == "M"], "pnorm")
##
## One-sample Kolmogorov-Smirnov test
##
## data: df$Month0[df$Sex == "M"]
## D = 1, p-value = 8.882e-16
## alternative hypothesis: two-sided
length(df$Month0[df$Sex == "M"])
## [1] 48
qqnorm( df$Month0[ df$Sex == "F" ] )
qqline( df$Month0[ df$Sex == "F" ] )
ks.test (df$Month0[df$Sex == "F"], "pnorm")
##
## One-sample Kolmogorov-Smirnov test
##
## data: df$Month0[df$Sex == "F"]
## D = 1, p-value = 8.882e-16
## alternative hypothesis: two-sided
length(df$Month0[df$Sex == "F"])
## [1] 48
library(car)
## Warning: package 'car' was built under R version 3.4.4
## Loading required package: carData
## Warning: package 'carData' was built under R version 3.4.4
bartlett.test( df$Month0 ~ df$Sex, data = df)
##
## Bartlett test of homogeneity of variances
##
## data: df$Month0 by df$Sex
## Bartlett's K-squared = 0.66588, df = 1, p-value = 0.4145
t.test( df$Month0[df$Sex=="M"],df$Month0[df$Sex=="F"], alternative = "t", var.equal= T)
##
## Two Sample t-test
##
## data: df$Month0[df$Sex == "M"] and df$Month0[df$Sex == "F"]
## t = -0.952, df = 94, p-value = 0.3435
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -1.1974887 0.4213205
## sample estimates:
## mean of x mean of y
## 9.934557 10.322642
qqnorm( df$Month0 )
qqline( df$Month0 )
ks.test (df$Month0, "pnorm")
##
## One-sample Kolmogorov-Smirnov test
##
## data: df$Month0
## D = 1, p-value = 1.332e-15
## alternative hypothesis: two-sided
length(df$Month0)
## [1] 96
qqnorm( df$Month3 )
qqline( df$Month3 )
ks.test (df$Month3, "pnorm")
##
## One-sample Kolmogorov-Smirnov test
##
## data: df$Month3
## D = 0.97877, p-value = 1.332e-15
## alternative hypothesis: two-sided
length(df$Month3)
## [1] 96
t.test(df$Month0, df$Month3, paired = TRUE, alternative = "t")
##
## Paired t-test
##
## data: df$Month0 and df$Month3
## t = 5.7578, df = 95, p-value = 1.043e-07
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## 1.314517 2.698015
## sample estimates:
## mean of the differences
## 2.006266
sessionInfo()
## R version 3.4.3 (2017-11-30)
## Platform: x86_64-w64-mingw32/x64 (64-bit)
## Running under: Windows 7 x64 (build 7601) Service Pack 1
##
## Matrix products: default
##
## locale:
## [1] LC_COLLATE=Spanish_Ecuador.1252 LC_CTYPE=Spanish_Ecuador.1252
## [3] LC_MONETARY=Spanish_Ecuador.1252 LC_NUMERIC=C
## [5] LC_TIME=Spanish_Ecuador.1252
##
## attached base packages:
## [1] stats graphics grDevices utils datasets methods base
##
## other attached packages:
## [1] car_3.0-0 carData_3.0-1
##
## loaded via a namespace (and not attached):
## [1] Rcpp_0.12.15 knitr_1.20 magrittr_1.5
## [4] rlang_0.2.0 stringr_1.3.0 tools_3.4.3
## [7] data.table_1.10.4-3 rio_0.5.10 htmltools_0.3.6
## [10] abind_1.4-5 yaml_2.1.18 readxl_1.0.0
## [13] rprojroot_1.3-2 digest_0.6.15 tibble_1.4.2
## [16] curl_3.2 evaluate_0.10.1 haven_1.1.1
## [19] rmarkdown_1.9 openxlsx_4.0.17 stringi_1.1.6
## [22] compiler_3.4.3 pillar_1.2.1 cellranger_1.1.0
## [25] forcats_0.3.0 backports_1.1.2 foreign_0.8-69