McNemar's Test Calculator
Enter a paired 2×2 table and find out whether two measures on the same subjects — two classifiers, two diagnostic tests, or a before/after change — differ significantly. Chi-square and exact binomial p-values, discordant pairs, and a plain-English verdict. No signup, sources cited.
How it works
McNemar's test compares two binary measurements taken on the samesubjects. Arrange the paired data as a 2×2 table where each cell counts subjects (or test items): a = both “yes”, b = first “yes” and second “no”, c = first “no” and second “yes”, d = both “no”. Cells b and c are the discordant pairs — the cases where the two measures disagree. Under the null hypothesis that the two measures are equivalent, disagreements should split evenly, so b and c are each expected to be (b + c)/2. Concordant cells a and d carry no information about that split and drop out of the statistic (McNemar, 1947).
The default statistic is the continuity-corrected chi-square (Edwards, 1948):
χ² = (|b − c| − 1)² / (b + c), df = 1
Turning the correction off gives the original uncorrected form, χ² = (b − c)² / (b + c). Because the reference distribution has one degree of freedom, the two-sided p-value equals 2 · (1 − Φ(√χ²)), where Φ is the standard-normal CDF; we evaluate Φ with a high-accuracy error-function approximation, no external library (NIST/SEMATECH handbook).
When the number of discordant pairs is small the chi-square approximation is unreliable, so for b + c < 25 the calculator switches to the exact binomial test. It treats the b vs c split as n = b + c coin flips with p = 0.5 and sums the two tails:
p = 2 · Σi=0…min(b,c) C(b + c, i) · 0.5(b + c), capped at 1.0
The binomial probabilities are built up multiplicatively so the coefficients never overflow, even for large counts. If b + c = 0 there are no disagreements and the test is undefined; the tool says so instead of dividing by zero. Alongside the p-value it reports the odds ratio b / c (which direction the disagreements favour), the marginal proportions (a + b)/N and (a + c)/N, and the total sample size N for interpretation. The corrected chi-square here matches R's mcnemar.test and the exact test matches statsmodels' mcnemar(exact=True).
Worked examples
Frequently asked questions
Sources & references
- McNemar, Q. (1947). Note on the sampling error of the difference between correlated proportions. Psychometrika 12(2), 153–157.
- Edwards, A. L. (1948). Note on the 'correction for continuity' in testing the significance of the difference between correlated proportions. Psychometrika 13(3), 185–187.
- NIST/SEMATECH e-Handbook of Statistical Methods — chi-square reference distribution and exact-binomial small-sample rule.
- Dietterich, T. G. (1998). Approximate Statistical Tests for Comparing Supervised Classification Learning Algorithms. Neural Computation 10(7), 1895–1923.
The formulas on this page were last cross-checked against these sources and against R's mcnemar.test and Python statsmodels on 2026-07-11.
Related tools
Comments & feedback
Spotted a bug or want an improvement? Tell us — our team reviews every comment, and good ideas get built. Comments are public and anonymous.
Found a bug, edge case, or want to suggest an improvement?
Email me at [email protected] — most fixes ship within 24 hours.