McNemar's Test

Tests paired proportions (before/after) via the discordant pairs – exact binomial test, χ² with and without continuity correction, confidence interval of the difference.

Statusvalidated
Version1.0.0
Minitab equivalentStat > Tables > McNemar's Test

Description

Table [[a, b], [c, d]]: rows = before (event, no event), columns = after; b = event → no event, c = no event → event. Exact test: c ~ Bin(b + c, 0.5), two-sided central min(1, 2·min(P(X ≤ c), P(X ≥ c))). χ² = (b − c)²/(b + c), corrected (|b − c| − 1)²/(b + c), 1 degree of freedom each (two-sided only). Difference = (c − b)/n with Wald interval, Var = ((b + c) − (b − c)²/n)/n². Without discordant pairs the test is not testable. Minitab check of the difference interval: Methods and Formulas page could not be retrieved – unverified (CI: Wald, no Minitab reference).

Formulas

χ²
Uncorrected
χ² (cc)
With continuity correction
Δ
Difference after − before, Wald

Assumptions

  • Paired observations, each pair in exactly one cell

Limitations

  • Only discordant pairs inform the test; below 10 the χ² approximation is unreliable, prefer the exact test
  • Difference CI: Wald, no Minitab reference

References

  • statsmodels 0.14.6: statsmodels.stats.contingency_tables.mcnemar