Statistical Analysis
McNemar’s Paired-Proportions Chi-Square Test & Edwards Continuity Correction
Test before-vs-after binary treatment shifts or matched classifier error rates using discordant pairs (b and c), Edwards continuity-corrected chi-square, and matched-pair odds ratio.
Why standard 2x2 Pearson chi-square is invalid on matched or pre/post subjects
When the same N subjects (or the same N test records evaluated by Model A and Model B) produce binary Yes/No outcomes before and after an intervention, observations are paired rather than independent. Concordant cells a (Yes -> Yes) and d (No -> No) carry zero directional evidence about marginal shift.
McNemar’s (1947) test focuses exclusively on the discordant off-diagonal counts b (Yes -> No) and c (No -> Yes): chi2 = (b - c)^2 / (b + c) with 1 degree of freedom. Applying Edwards’ (1948) continuity correction—(ABS(b - c) - 1)^2 / (b + c)—aligns the discrete binomial tail closely with the 95% critical threshold 3.8415.
| Matched Statistic | Formula | Example (b=22, c=8) | Interpretation |
|---|---|---|---|
| Discordant Pairs (b + c) | C2 + B3 | 30 | Informative switchers |
| Uncorrected McNemar Chi2 | (b - c)^2 / (b + c) | 6.5333 | Asymptotic df=1 statistic |
| Edwards Corrected Chi2 | (MAX(0, ABS(b - c) - 1))^2 / (b + c) | 5.6333 | Exceeds 3.8415 (p < 0.05) |
| Matched-Pair Odds Ratio | b / c | 2.7500 | 2.75x Yes->No vs No->Yes |
Uncorrected & Edwards Continuity-Corrected McNemar Formulas
Guard b + c = 0 (no discordant pairs -> statistic = 0) and clamp ABS(b - c) - 1 at 0 so identical discordant counts (b = c) never square -1 into a spurious +1/(2b) statistic!
=IF(C2 + B3 = 0, 0, ROUND((MAX(0, ABS(C2 - B3) - 1) ^ 2) / (C2 + B3), 4))Matched-Pair Marginal Shift Difference
Notice that the net difference between pre-test and post-test positive proportions (a+b)/N - (a+c)/N simplifies identically to (b - c) / N.
=ROUND((C2 - B3) / SUM(B2:C3), 4)Try the example
Use the original values or change them to test your understanding.