例題:
「表 1 のようなクロス集計表に基づき,“甘いものが好きか嫌いか”と“虫歯の有無”の間に関連があるか検定しなさい。」
| 虫歯 | ||||
|---|---|---|---|---|
| あり | なし | 合計 | ||
| 甘いもの | 好き | 13 | 4 | 17 |
| 嫌い | 6 | 14 | 20 | |
| 合計 | 19 | 18 | 37 | |
R による解析:
> tbl3 <- matrix(c(13, 4, 6, 14), ncol=2, byrow=TRUE)
> tbl3
[,1] [,2]
[1,] 13 4
[2,] 6 14
> # 両側検定
> fisher.test(tbl3)
Fisher's Exact Test for Count Data
data: tbl3
p-value = 0.008138
alternative hypothesis: true odds ratio is not equal to 1
95 percent confidence interval:
1.440142 43.843385
sample estimates:
odds ratio
7.11257
> # 片側検定
> fisher.test(tbl3, alternative="g")
Fisher's Exact Test for Count Data
data: tbl3
p-value = 0.005855
alternative hypothesis: true odds ratio is greater than 1
95 percent confidence interval:
1.770426 Inf
sample estimates:
odds ratio
7.11257