例えばn=14の前後比較・・・
下のデータをコピーして
前 後
90 98
90 95
92 77
91 84
83 75
93 88
89 89
81 88
80 86
77 86
78 79
77 90
76 88
79 99
Rに貼り付け
x<-read.table("clipboard",header=T)
対応のあるデータなので「差」を検定することになる
差<-c(x$後-x$前)
帰無仮説の下で、この差は自由度13のt分布に従うことから
t.test(差)
One Sample t-test
data: 差
t = 1.2899, df = 13, p-value = 0.2195
alternative hypothesis: true mean is not equal to 0
95 percent confidence interval:
-2.217176 8.788605
sample estimates:
mean of x
3.285714
帰無仮説(差がない)が正しいという仮説のもとでp値は0.2195
「起こりにくい」とは言えないですね!
次の式でも同様に求められます
t.test(x$後,x$前,paired=TRUE)
99%信頼区間を求めたいなら・・・
conf.level=0.99
t.test(x$後,x$前,paired=TRUE,conf.level=0.99)
> t.test(x$後,x$前,paired=TRUE,conf.level=0.99)
Paired t-test
data: x$後 and x$前
t = 1.2899, df = 13, p-value = 0.2195
alternative hypothesis: true difference in means is not equal to 0
99 percent confidence interval:
-4.387154 10.958582
sample estimates:
mean of the differences
3.285714