What the McNemar test does
The McNemar test compares two proportions measured on the same subjects: the share of people who answer yes before and after a campaign, the positive rate of two diagnostic tests applied to the same patients, or the pass rate of students on two exams. Because the measurements are paired, the usual chi-square test for two independent proportions does not apply.
The 2 × 2 table
| Second: yes | Second: no | |
|---|---|---|
| First: yes | a | b |
| First: no | c | d |
Only the discordant pairs b and c carry information about a change: subjects in a and d gave the same answer twice.
The formulas
- With the continuity correction (Edwards): χ² = (|b − c| − 1)² ÷ (b + c), 1 degree of freedom.
- Without correction: χ² = (b − c)² ÷ (b + c).
- Exact test: under the null hypothesis, b follows Binomial(b + c, ½), so p = 2 × P(X ≤ min(b, c)).
Example
100 people are asked whether they would buy a product, before and after seeing an ad: a = 30, b = 15, c = 5, d = 50.
- yes before: 45%; yes after: 35%, a drop of 10 points;
- χ² with correction = (10 − 1)² ÷ 20 = 4.05, p ≈ 0.044;
- without correction: χ² = 5, p ≈ 0.025;
- exact p ≈ 0.041.
All three methods agree that the change is significant at α = 0.05: the ad reduced purchase intent.
Which p-value to report?
- With fewer than about 25 discordant pairs, use the exact binomial p-value.
- With more, the corrected chi-square is standard; the uncorrected version is slightly less conservative and is also widely used.
Effect size
The paired odds ratio b ÷ c (here 3) says how many more subjects switched in one direction than the other. The difference in proportions (c − b) ÷ N is the change in percentage points.
Limits
- The test ignores the concordant pairs, so a large a or d does not add power.
- It applies to two measurements only. For three or more paired measurements of a yes/no outcome, use Cochran’s Q test.