McNemar’s Test
Test whether paired yes/no answers changed — chi-square with the exact binomial alternative.
Based on the 24 discordant pairs (b = 18, c = 6) out of 100 total. Concordant pairs carry no information about change.
Chi-square with 1 degree of freedom, continuity-corrected.
With only 24 discordant pairs the chi-square approximation is unreliable — report the exact test instead.
McNemar’s test uses only the pairs that changed. With 18 switching from yes to no and 6 from no to yes, the continuity-corrected chi-square is (|18 − 6| − 1)² ÷ 24 = 5.04 on 1 degree of freedom, giving p = .025 — a significant shift.
Why the agreements are discarded
McNemar’s test is for paired binary data: the same people measured twice, or matched cases and controls. The question is whether the proportion answering yes changed between the two occasions.
Participants who answered the same way both times carry no information about change. Someone who said yes before and yes after tells you nothing about the direction of any shift — only the discordant pairs do. So the test looks solely at the two off-diagonal cells: how many switched one way against how many switched the other. If the intervention did nothing, those two counts should be roughly equal.
Why a chi-square test is not the right tool here
A standard chi-square test of independence assumes the two samples are independent, which is exactly what paired data are not. Applying it to before-and-after data on the same people ignores the pairing and generally understates the evidence for change. McNemar’s test exists precisely to handle that dependence.
b and c are the two discordant counts — those who changed in each direction. The concordant cells a and d do not appear in the formula at all.
Worked example: 30 / 18 / 6 / 46
Count the switchers, then test whether the two directions are balanced:
- 1 Build the paired 2×2 table. Yes both times = 30, yes then no = 18, no then yes = 6, no both times = 46. Total N = 100.
- 2 Identify the discordant pairs. b = 18 and c = 6, so 24 of the 100 participants changed their answer.
- 3 Take the difference. 18 − 6 = 12. If the intervention had no effect, this should be near zero.
- 4 Apply the corrected formula. (|12| − 1)² ÷ 24 = 121 ÷ 24 = 5.04.
- 5 Find the p-value. A chi-square of 5.04 with 1 degree of freedom gives p = .025.
- 6 Check the exact test. With 24 discordant pairs the exact binomial gives p = .023 — the two agree closely here.
Which test for which design
The distinction is whether the two sets of observations come from the same units.
| Data | Test |
|---|---|
| Paired binary, two occasions | McNemar’s test |
| Paired binary, three or more occasions | Cochran’s Q |
| Independent binary groups | Chi-square or Fisher’s exact |
| Paired continuous or ordinal | Wilcoxon signed-rank |
| Paired binary agreement, not change | Cohen’s kappa |
The continuity correction and the exact test
Yates’ continuity correction subtracts 1 before squaring, compensating for using a continuous chi-square distribution to approximate discrete counts. It makes the test more conservative. Opinion is genuinely divided: the correction is standard in many textbooks, while others consider it over-cautious. Stating which you used is what matters.
The argument becomes moot when the number of discordant pairs is small. Below about 25, the chi-square approximation is unreliable in either form and the exact binomial test should be reported instead — it treats the b discordant switches as draws from a binomial with p = 0.5 and computes the probability directly, with no approximation involved.
One design point: a large total sample does not rescue a small discordant count. A study of 500 people in which only 9 changed their answer is a 9-pair test, and its power is set by that 9, not by the 500.