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.