McNemar's Test Calculator

Test whether the marginal proportions of paired nominal data changed. Enter the two discordant counts (b and c) from your 2×2 table to get the chi-square statistic and p-value.

Quick Facts

Method
Chi-square on discordant pairs: χ² = (b−c)²/(b+c), df = 1
Concordant cells a and d are ignored; only the pairs that switched matter.

Your Results

Calculated
Chi-square statistic
-
χ² with df = 1
p-value
-
Two-sided
Discordant total (b + c)
-
Informative pairs
Significance at α = 0.05
-
Interpretation

Ready

Enter your discordant counts b and c, then run the test.

Frequently Asked Questions

Why does the test ignore the a and d cells?
Subjects in cells a and d gave the same answer on both measurements, so they provide no evidence about whether the overall proportion changed. Only the discordant pairs — b and c — record a switch, and McNemar's test compares those two counts against each other.
When should I use the continuity correction or an exact test?
Use the uncorrected statistic when the discordant total b + c is reasonably large (roughly 25 or more). When b + c is small, the chi-square approximation overstates significance; switch to Edwards' continuity correction, (|b−c|−1)²/(b+c), or use the exact binomial test with n = b + c and p = 0.5, which is always valid.
What is the difference between McNemar's test and a chi-square test of independence?
A chi-square test of independence compares two independent groups. McNemar's test is for paired data — the same subjects measured twice, or matched pairs. Applying an independence test to paired data ignores the pairing and gives the wrong answer, usually understating significance.

What McNemar's test measures

McNemar's test is a statistical test for paired nominal data — the same subjects measured twice on a yes/no (binary) outcome. It answers one question: did the proportion of "yes" responses change between the two measurements? Typical uses are before-and-after studies, two diagnostic tests run on the same patients, or matched case-control pairs. Because the two observations come from the same subject, an ordinary chi-square test of independence is invalid; McNemar's test is the correct paired alternative.

The 2×2 table

Arrange the paired results in a 2×2 table. The rows are the first measurement, the columns are the second:

  • a — positive on both measurements (concordant)
  • b — positive then negative (discordant)
  • c — negative then positive (discordant)
  • d — negative on both measurements (concordant)

The two concordant cells, a and d, contain subjects who did not change, so they carry no information about a shift in the marginal proportion. McNemar's test discards them and works only with the two discordant cells, b and c. That is why this calculator asks only for b and c.

The formula

The uncorrected McNemar statistic is:

χ² = (b − c)² / (b + c)

Under the null hypothesis that b and c are equally likely, this statistic follows a chi-square distribution with 1 degree of freedom. The p-value is the upper-tail area of that distribution beyond the observed χ². A large gap between b and c produces a large statistic and a small p-value, signalling a real change in the marginal proportion.

For small discordant totals (a common threshold is b + c < 25), the chi-square approximation is inaccurate. Edwards' continuity correction, χ² = (|b − c| − 1)² / (b + c), pulls the statistic toward a more conservative value. For very small samples, the exact binomial test — treating b as a draw from Binomial(b + c, 0.5) — is the gold standard.

Worked example

Suppose 52 patients switched results between two diagnostic tests: b = 12 went from positive to negative and c = 40 went from negative to positive. Then χ² = (12 − 40)² / (12 + 40) = (−28)² / 52 = 784 / 52 ≈ 15.08. With df = 1 the two-sided p-value is about 0.0001, so the two tests disagree far more than chance would allow.