c:ma:2016:schedule:week09_answer
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| c:ma:2016:schedule:week09_answer [2016/11/08 23:51] – hkimscil | c:ma:2016:schedule:week09_answer [2016/11/09 01:22] (current) – [E.g. 6] hkimscil | ||
|---|---|---|---|
| Line 144: | Line 144: | ||
| 3.994455 6.672876 | 3.994455 6.672876 | ||
| - | > t.test(MPG.city~Origin) | + | > plot(MPG.city~Origin) |
| + | </ | ||
| + | |||
| + | {{t-test_mpg.city.png}} | ||
| + | |||
| + | < | ||
| Welch Two Sample t-test | Welch Two Sample t-test | ||
| Line 187: | Line 192: | ||
| | | ||
| 4.151337 6.247990 | 4.151337 6.247990 | ||
| + | > plot(MPG.highway~Origin) | ||
| + | </ | ||
| - | > t.test(MPG.highway~Origin) | + | {{t-test_mpghighway.png}} |
| + | |||
| + | < | ||
| Welch Two Sample t-test | Welch Two Sample t-test | ||
| Line 214: | Line 223: | ||
| USA | USA | ||
| 1.1353757 0.7171563 | 1.1353757 0.7171563 | ||
| + | > plot(EngineSize~Origin) | ||
| > | > | ||
| - | > t.test(EngineSize~Origin) | + | </ |
| + | {{t-test_enginesize.png}} | ||
| + | < | ||
| Welch Two Sample t-test | Welch Two Sample t-test | ||
| Line 238: | Line 249: | ||
| - null hypothesis | - null hypothesis | ||
| - test result | - test result | ||
| + | |||
| + | < | ||
| + | > attach(sb) | ||
| + | The following objects are masked from sb (pos = 3): | ||
| + | |||
| + | drivers, DriversKilled, | ||
| + | PetrolPrice, | ||
| + | |||
| + | The following object is masked from package: | ||
| + | |||
| + | drivers | ||
| + | > | ||
| + | </ | ||
| + | |||
| + | < | ||
| + | $`0` | ||
| + | Min. 1st Qu. Median | ||
| + | | ||
| + | |||
| + | $`1` | ||
| + | Min. 1st Qu. Median | ||
| + | | ||
| + | > | ||
| + | |||
| + | > tapply(DriversKilled, | ||
| + | | ||
| + | 24.26088 22.22860 | ||
| + | </ | ||
| + | |||
| + | < | ||
| + | |||
| + | Welch Two Sample t-test | ||
| + | |||
| + | data: DriversKilled by law | ||
| + | t = 5.1253, df = 29.609, p-value = 1.693e-05 | ||
| + | alternative hypothesis: true difference in means is not equal to 0 | ||
| + | 95 percent confidence interval: | ||
| + | | ||
| + | sample estimates: | ||
| + | mean in group 0 mean in group 1 | ||
| + | | ||
| + | </ | ||
| ====== E.g. 3 ====== | ====== E.g. 3 ====== | ||
| Line 245: | Line 298: | ||
| - 테스트를 한 후 | - 테스트를 한 후 | ||
| - 결과를 보고하시오. | - 결과를 보고하시오. | ||
| + | |||
| + | < | ||
| + | |||
| + | . . . . | ||
| + | |||
| + | > md = subset(anorexia, | ||
| + | > md | ||
| + | Treat Prewt Postwt | ||
| + | 56 FT 83.8 95.2 | ||
| + | 57 FT 83.3 94.3 | ||
| + | 58 FT 86.0 91.5 | ||
| + | 59 FT 82.5 91.9 | ||
| + | 60 FT 86.7 100.3 | ||
| + | 61 FT 79.6 76.7 | ||
| + | 62 FT 76.9 76.8 | ||
| + | 63 FT 94.2 101.6 | ||
| + | 64 FT 73.4 94.9 | ||
| + | 65 FT 80.5 75.2 | ||
| + | 66 FT 81.6 77.8 | ||
| + | 67 FT 82.1 95.5 | ||
| + | 68 FT 77.6 90.7 | ||
| + | 69 FT 83.5 92.5 | ||
| + | 70 FT 89.9 93.8 | ||
| + | 71 FT 86.0 91.7 | ||
| + | 72 FT 87.3 98.0 | ||
| + | |||
| + | > t.test(md$Prewt, | ||
| + | |||
| + | Paired t-test | ||
| + | |||
| + | data: md$Prewt and md$Postwt | ||
| + | t = -4.1849, df = 16, p-value = 0.0007003 | ||
| + | alternative hypothesis: true difference in means is not equal to 0 | ||
| + | 95 percent confidence interval: | ||
| + | | ||
| + | sample estimates: | ||
| + | mean of the differences | ||
| + | -7.264706 | ||
| + | </ | ||
| + | |||
| + | |||
| ====== E.g. 4 ====== | ====== E.g. 4 ====== | ||
| <WRAP box> | <WRAP box> | ||
| Line 251: | Line 345: | ||
| </ | </ | ||
| 두 그룹의 평균의 차이를 비교하시오. | 두 그룹의 평균의 차이를 비교하시오. | ||
| + | |||
| + | < | ||
| + | [1] 175 168 168 190 156 181 182 175 174 179 | ||
| + | > b | ||
| + | [1] 185 169 173 173 188 186 175 174 179 180 | ||
| + | > ab <- data.frame(a, | ||
| + | > ab | ||
| + | | ||
| + | 1 175 185 | ||
| + | 2 168 169 | ||
| + | 3 168 173 | ||
| + | 4 190 173 | ||
| + | 5 156 188 | ||
| + | 6 181 186 | ||
| + | 7 182 175 | ||
| + | 8 175 174 | ||
| + | 9 174 179 | ||
| + | 10 179 180 | ||
| + | > | ||
| + | |||
| + | > summary(ab) | ||
| + | | ||
| + | | ||
| + | 1st Qu.: | ||
| + | | ||
| + | | ||
| + | 3rd Qu.: | ||
| + | | ||
| + | |||
| + | > abs <- stack(ab) | ||
| + | > tapply(abs$values, | ||
| + | $a | ||
| + | Min. 1st Qu. Median | ||
| + | 156.0 | ||
| + | |||
| + | $b | ||
| + | Min. 1st Qu. Median | ||
| + | 169.0 | ||
| + | |||
| + | > tapply(abs$values, | ||
| + | | ||
| + | 9.342852 6.442912 | ||
| + | > | ||
| + | |||
| + | > t.test(ab$a, | ||
| + | |||
| + | Welch Two Sample t-test | ||
| + | |||
| + | data: ab$a and ab$b | ||
| + | t = -0.94737, df = 15.981, p-value = 0.3576 | ||
| + | alternative hypothesis: true difference in means is not equal to 0 | ||
| + | 95 percent confidence interval: | ||
| + | | ||
| + | sample estimates: | ||
| + | mean of x mean of y | ||
| + | 174.8 | ||
| + | |||
| + | </ | ||
| ====== E.g. 5 ====== | ====== E.g. 5 ====== | ||
| Line 257: | Line 409: | ||
| 아이스크림의 박테리아가 0.3 MPN/g 보다 커서 유통되기에 위험하다고 할 수 있을까? | 아이스크림의 박테리아가 0.3 MPN/g 보다 커서 유통되기에 위험하다고 할 수 있을까? | ||
| + | < | ||
| + | > ir | ||
| + | [1] 0.593 0.142 0.329 0.691 0.231 0.793 0.519 0.392 0.418 | ||
| + | |||
| + | > t.test(ir, mu=.3) | ||
| + | |||
| + | One Sample t-test | ||
| + | |||
| + | data: ir | ||
| + | t = 2.2051, df = 8, p-value = 0.05853 | ||
| + | alternative hypothesis: true mean is not equal to 0.3 | ||
| + | 95 percent confidence interval: | ||
| + | | ||
| + | sample estimates: | ||
| + | mean of x | ||
| + | 0.4564444 | ||
| + | |||
| + | > | ||
| + | |||
| + | > t.test(ir, alternative=" | ||
| + | |||
| + | One Sample t-test | ||
| + | |||
| + | data: ir | ||
| + | t = 2.2051, df = 8, p-value = 0.02927 | ||
| + | alternative hypothesis: true mean is greater than 0.3 | ||
| + | 95 percent confidence interval: | ||
| + | | ||
| + | sample estimates: | ||
| + | mean of x | ||
| + | 0.4564444 | ||
| + | |||
| + | > | ||
| + | </ | ||
| ====== E.g. 6 ====== | ====== E.g. 6 ====== | ||
| Line 264: | Line 450: | ||
| 흡연이 기억에 영향을 준다고 할 수 있을까? | 흡연이 기억에 영향을 준다고 할 수 있을까? | ||
| + | < | ||
| + | > smoke <- c(18, | ||
| + | > nosmoke <- c(16, | ||
| + | |||
| + | > sn <- data.frame(smoke, | ||
| + | > ss <- stack(sn) | ||
| + | > plot(ss$values~ss$ind) | ||
| + | </ | ||
| + | |||
| + | < | ||
| + | |||
| + | Welch Two Sample t-test | ||
| + | |||
| + | data: ss$values by ss$ind | ||
| + | t = -2.2573, df = 16.376, p-value = 0.03798 | ||
| + | alternative hypothesis: true difference in means is not equal to 0 | ||
| + | 95 percent confidence interval: | ||
| + | | ||
| + | sample estimates: | ||
| + | mean in group nosmoke | ||
| + | | ||
| + | |||
| + | > | ||
| + | |||
| + | > | ||
| + | </ | ||
| ====== E.g. 7 ====== | ====== E.g. 7 ====== | ||
| - MASS package를 불러온 후, survey 데이터를 활용하여 담배와 운동량 간의 관계에 대한 가설테스트를 하시오. | - MASS package를 불러온 후, survey 데이터를 활용하여 담배와 운동량 간의 관계에 대한 가설테스트를 하시오. | ||
c/ma/2016/schedule/week09_answer.1478649113.txt.gz · Last modified: by hkimscil
