User Tools

Site Tools


c:ma:2016:schedule:week09_answer

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
c:ma:2016:schedule:week09_answer [2016/11/09 09:22] – [E.g. 3] hkimscilc:ma:2016:schedule:week09_answer [2016/11/09 09:52] (current) – [E.g. 6] hkimscil
Line 345: Line 345:
 </WRAP> </WRAP>
 두 그룹의 평균의 차이를 비교하시오.  두 그룹의 평균의 차이를 비교하시오. 
 +
 +<code>> a
 + [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,b)
 +> ab
 +       b
 +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)
 +                            
 + Min.   :156.0   Min.   :169.0  
 + 1st Qu.:169.5   1st Qu.:173.2  
 + Median :175.0   Median :177.0  
 + Mean   :174.8   Mean   :178.2  
 + 3rd Qu.:180.5   3rd Qu.:183.8  
 + Max.   :190.0   Max.   :188.0  
 +
 +> abs <- stack(ab)
 +> tapply(abs$values, abs$ind, summary)
 +$a
 +   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
 +  156.0   169.5   175.0   174.8   180.5   190.0 
 +
 +$b
 +   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
 +  169.0   173.2   177.0   178.2   183.8   188.0 
 +
 +> tapply(abs$values, abs$ind, sd)
 +              b 
 +9.342852 6.442912 
 +
 +
 +> t.test(ab$a,ab$b)
 +
 + 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:
 + -11.008795   4.208795
 +sample estimates:
 +mean of x mean of y 
 +    174.8     178.2 
 +
 +</code>
  
 ====== E.g. 5 ====== ====== E.g. 5 ======
Line 351: Line 409:
 아이스크림의 박테리아가 0.3 MPN/g 보다 커서 유통되기에 위험하다고 할 수 있을까? 아이스크림의 박테리아가 0.3 MPN/g 보다 커서 유통되기에 위험하다고 할 수 있을까?
  
 +<code>> ir <- c(0.593, 0.142, 0.329, 0.691, 0.231, 0.793, 0.519, 0.392, 0.418)
 +> 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:
 + 0.2928381 0.6200508
 +sample estimates:
 +mean of x 
 +0.4564444 
 +
 +
 +
 +> t.test(ir, alternative="greater", mu=.3)
 +
 + 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:
 + 0.3245133       Inf
 +sample estimates:
 +mean of x 
 +0.4564444 
 +
 +
 +</code>
  
 ====== E.g. 6 ====== ====== E.g. 6 ======
Line 358: Line 450:
 흡연이 기억에 영향을 준다고 할 수 있을까? 흡연이 기억에 영향을 준다고 할 수 있을까?
  
 +<code>
 +> smoke <- c(18,22,21,17,20,17,23,20,22,21)
 +> nosmoke <- c(16,20,14,21,20,18,13,15,17,21)
 +
 +> sn <- data.frame(smoke, nosmoke)
 +> ss <- stack(sn)
 +> plot(ss$values~ss$ind)
 +</code>
 +
 +<code>> t.test(values$ss~ind$ss)
 +
 + 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:
 + -5.0371795 -0.1628205
 +sample estimates:
 +mean in group nosmoke   mean in group smoke 
 +                 17.5                  20.1 
 +
 +
 +
 +
 +</code>
 ====== E.g. 7 ====== ====== E.g. 7 ======
   - MASS package를 불러온 후, survey 데이터를 활용하여 담배와 운동량 간의 관계에 대한 가설테스트를 하시오.    - MASS package를 불러온 후, survey 데이터를 활용하여 담배와 운동량 간의 관계에 대한 가설테스트를 하시오. 
c/ma/2016/schedule/week09_answer.1478652738.txt.gz · Last modified: 2016/11/09 09:22 by hkimscil

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki