例題:
二群の平均値の差について,有意水準 5% で両側検定しなさい。
| gr1 | 22.4 | 19.7 | 23.6 | 16.9 | 17.3 | 20.0 | 18.5 | 19.9 | 21.0 | 16.9 |
|---|---|---|---|---|---|---|---|---|---|---|
| gr2 | 20.5 | 21.5 | 19.3 | 21.1 | 16.8 | 18.2 | 20.1 | 22.7 | 17.7 | 17.5 |
R による解析:
> gr1 <- c(22.4, 19.7, 23.6, 16.9, 17.3, 20.0, 18.5, 19.9, 21.0, 16.9) # 第一群
> gr2 <- c(20.5, 21.5, 19.3, 21.1, 16.8, 18.2, 20.1, 22.7, 17.7, 17.5) # 第二群
> t.test(gr1, gr2, var.equal=TRUE) # 二群の分散が等しいことを仮定する場合(var.equal=TRUE)
Two Sample t-test
data: gr1 and gr2
t = 0.084, df = 18, p-value = 0.934
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
-1.919742 2.079742
sample estimates:
mean of x mean of y
19.62 19.54
> t.test(gr1, gr2) # 二群の分散が等しいことを仮定しない場合
Welch Two Sample t-test
data: gr1 and gr2
t = 0.084, df = 17.572, p-value = 0.934
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
-1.923243 2.083243
sample estimates:
mean of x mean of y
19.62 19.54