例題:
「内閣の支持率調査で,同じ対象者に 1 月と 4 月の 2 回調査をした結果は表 1 のようになった。 この 3 ヵ月間に支持率に変化があったといえるかどうか検定しなさい。」
| 4 月 | ||||
|---|---|---|---|---|
| 支持する | 支持しない | 合計 | ||
| 1 月 | 支持する | 48 | 28 | 76 |
| 支持しない | 35 | 53 | 88 | |
| 合計 | 83 | 81 | 164 | |
R による解析:
> mcnemar.test(matrix(c(48, 28, 35, 53), 2, 2), correct=FALSE) # 連続性の補正をしない場合
McNemar's Chi-squared test
data: matrix(c(48, 28, 35, 53), 2, 2)
McNemar's chi-squared = 0.7778, df = 1, p-value = 0.3778
> mcnemar.test(matrix(c(48, 28, 35, 53), 2, 2)) # 連続性の補正をする場合
McNemar's Chi-squared test with continuity correction
data: matrix(c(48, 28, 35, 53), 2, 2)
McNemar's chi-squared = 0.5714, df = 1, p-value = 0.4497
> binom.test(c(35, 28)) # 二項検定による正確な有意確率
Exact binomial test
data: 35 and 63
number of successes = 35, number of trials = 63, p-value = 0.45
alternative hypothesis: true probability of success is not equal to 0.5
95 percent confidence interval:
0.4248876 0.6808269
sample estimates:
probability of success
0.5555556