User Tools

Site Tools


r:general_statistics

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
r:general_statistics [2017/11/06 07:58] – [e.g.,] hkimscilr:general_statistics [2019/10/11 07:56] (current) – [Forming a Confidence Interval for a Mean] hkimscil
Line 497: Line 497:
 ====== Forming a Confidence Interval for a Mean ====== ====== Forming a Confidence Interval for a Mean ======
  
-<code>> s <- sd(x)+<code> 
 +> set.seed(1024) 
 +> x <- rnorm(50, mean=100, sd=15) 
 +> s <- sd(x)
 > m <- mean(x) > m <- mean(x)
 > n <- length(x) > n <- length(x)
Line 509: Line 512:
 > SE > SE
 [1] 2.458358 [1] 2.458358
-<- qt(.975, df=n-1)*SE+## qt fun: qt(prob, df) zscore 2점에 해당하는 점수는? 
 +qtv <- qt(.975, df=n-1) 
 +> qtv 
 +[1]  
 +## qtv는 2에 해당하는 95퍼센트 CL  
 +## 이 때의 CI는  
 +> E <- qtv*SE 
 > E > E
 [1] 4.940254 [1] 4.940254
Line 517: Line 526:
 </code> </code>
  
-<code>> t.test(x)+<code> 
 +> t.test(x, mu=98)
  
  One Sample t-test  One Sample t-test
  
 data:  x data:  x
-t = 39.052, df = 49, p-value < 2.2e-16 +t = 0.37089, df = 49, p-value = 0.7123 
-alternative hypothesis: true mean is not equal to 0+alternative hypothesis: true mean is not equal to 98
 95 percent confidence interval: 95 percent confidence interval:
-  91.0636 100.9441+  94.32303 103.34143
 sample estimates: sample estimates:
 mean of x  mean of x 
- 96.00386 + 98.83223  
 + 
 +> t.test(x, mu=100) 
 + 
 + One Sample t-test 
 + 
 +data:  x 
 +t = -0.52043, df = 49, p-value = 0.6051 
 +alternative hypothesis: true mean is not equal to 100 
 +95 percent confidence interval: 
 +  94.32303 103.34143 
 +sample estimates: 
 +mean of x  
 + 98.83223  
 + 
 +> t.test(x, mu=95) 
 + 
 + One Sample t-test 
 + 
 +data:  x 
 +t = 1.7079, df = 49, p-value = 0.09399 
 +alternative hypothesis: true mean is not equal to 95 
 +95 percent confidence interval: 
 +  94.32303 103.34143 
 +sample estimates: 
 +mean of x  
 + 98.83223  
 + 
 +
  
 </code> </code>
Line 793: Line 831:
 <code># Same for wide data (two separate vectors) <code># Same for wide data (two separate vectors)
 > t.test(sleep.wide$group1, sleep.wide$group2, paired=TRUE) > t.test(sleep.wide$group1, sleep.wide$group2, paired=TRUE)
 +
 + Paired t-test
 +
 +data:  sleep_wide$group1 and sleep_wide$group2
 +t = -4.0621, df = 9, p-value = 0.002833
 +alternative hypothesis: true difference in means is not equal to 0
 +95 percent confidence interval:
 + -2.4598858 -0.7001142
 +sample estimates:
 +mean of the differences 
 +                  -1.58 
 +
 </code> </code>
  
 The paired t-test is equivalent to testing whether difference between each pair of observations has a population mean of 0. (See below for comparing a single group to a population mean.) The paired t-test is equivalent to testing whether difference between each pair of observations has a population mean of 0. (See below for comparing a single group to a population mean.)
  
-<code>> t.test(sleep.wide$group1 - sleep.wide$group2, mu=0, var.equal=TRUE) +<code>> t.test(sleep_wide$group1 - sleep_wide$group2, mu=0, var.equal=TRUE) 
-> Error in t.test(sleep.wide$group1 - sleep.wide$group2, mu 0var.equal = TRUE)object 'sleep.wide' not found+ 
 + One Sample t-test 
 + 
 +data:  sleep_wide$group1 - sleep_wide$group2 
 +t = -4.0621df 9p-value = 0.002833 
 +alternative hypothesis: true mean is not equal to 0 
 +95 percent confidence interval: 
 + -2.4598858 -0.7001142 
 +sample estimates: 
 +mean of x  
 +    -1.58  
 </code> </code>
  
r/general_statistics.1509924499.txt.gz · Last modified: 2017/11/06 07:58 by hkimscil

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki