McNemar test calculator

Test whether a yes/no outcome changed between two paired measurements. Exact binomial p for small samples, continuity-corrected chi-square for larger ones.

After: yesAfter: no
Before: yes
Before: no
Each cell counts pairs (or people), not measurements. The highlighted cells (b, c) are the pairs that changed.
p < .001χ² with continuity correction
The proportion of “yes” changed significantly from before to after (α = .05).
Yes, before
59%
Yes, after
55%
Discordant pairs b + c
150 + 86 = 236
Exact p (binomial)
< .001
Mid-p
< .001
χ² (corrected)
16.818, p < .001
χ² (uncorrected)
17.356, p < .001
Odds ratio b/c
1.744
OR exact 95% CI
1.329, 2.301
Difference in proportions
4 pts

χ²(1, N = 1600) = 16.82, p < .001, OR = 1.74, 95% CI [1.33, 2.3]

The formulas

χ² = (|b − c| − 1)² / (b + c) df = 1exact p = 2 · P(X ≤ min(b, c)), X ~ Binomial(b + c, ½)OR = b / c

The default example is Agresti's presidential-approval data used in R's ?mcnemar.test: 1,600 people asked twice, 150 switched from approve to disapprove and 86 the other way. R gives χ² = 16.82, p < .001, and so does this calculator. The headline p uses the exact test when b + c < 25, otherwise the corrected chi-square.

McNemar vs chi-square vs Fisher

Use McNemar when the same units appear in both rows and columns. When the two groups are different people, use the chi-square test or, for small counts, Fisher's exact test. For paired continuous or ordinal data, the Wilcoxon signed-rank test is the counterpart.

Frequently asked questions

When do I use the McNemar test?

For a yes/no outcome measured twice on the same people (before and after, two raters, two diagnostic tests on one sample) or on matched pairs. It tests whether the proportion of “yes” changed. A chi-square test of independence would be wrong here because the observations are not independent.

Why does McNemar only use the discordant cells?

Pairs that answered the same both times (yes–yes, no–no) carry no information about change. The test compares the two kinds of switch, b (yes→no) and c (no→yes); under the null hypothesis each is equally likely.

Exact McNemar or chi-square?

If b + c is small (under about 25), use the exact binomial p-value. With more discordant pairs the continuity-corrected chi-square is a good approximation; it is what R’s mcnemar.test reports by default.

What is the McNemar odds ratio?

The paired (conditional) odds ratio b/c: how many times more often people switch one way than the other. Its exact confidence interval comes from the Clopper–Pearson interval for b/(b + c).

How do I report a McNemar test?

Give the paired proportions, then the statistic and p: “χ²(1, N = 1600) = 16.82, p < .001, OR = 1.74, 95% CI [1.33, 2.30]”, or for small samples “exact McNemar test, p = .039”.

What is the difference between McNemar and Cochran’s Q?

Cochran’s Q extends McNemar to three or more related yes/no measurements, just as repeated-measures ANOVA extends the paired t-test.