Categorical › Contingency / proportions

McNemar's test

McNemar's test tests symmetry in a 2 × 2 table of paired binary observations. The paired counterpart to chi-square / Fisher.

What is McNemar's test?

When the same subject is measured twice (before/after, two raters), the resulting 2 × 2 table has two off-diagonal cells (b = before yes / after no; c = before no / after yes) that capture all the information about change. McNemar's test asks whether b = c (no net shift) using χ² = (b − c)² / (b + c) ∼ χ²₁ under H₀.

For small (b + c) (< 25 or so), use the exact binomial version: under H₀, b ∼ Binomial(b + c, 0.5). We run the exact form automatically when the count is small.

Applying a regular chi-square to paired data is wrong — it treats the two columns as independent and discards the pairing. If your design pairs, McNemar is the right test.

When should I use McNemar's test?

  • Before / after binary outcomes on the same subject.
  • Two raters classifying the same subjects into the same two categories.
  • Two diagnostic tests on the same patients (positive / negative each).

What data does it need?

Two binary columns paired by row.

What does it report?

χ² statistic, df = 1, p-value (exact for small counts).

What does it assume?

  • Independent pairs.
  • Binary outcome.
  • Marginal counts are not the quantity of interest — only the discordant pairs are.

Formula

χ² = (b − c)² / (b + c) ∼ χ²₁ (asymptotic)

How do I interpret the result?

A significant McNemar test means the proportion changing from 0 → 1 differs from the proportion changing 1 → 0. Report the two discordant counts alongside the test.

If the question is 'did the marginal positivity rate change?' (rather than 'is there net asymmetry'), the answer is the same — McNemar's test of symmetry is equivalent to testing whether the marginal rates differ in paired binary data.

See also

References

  • McNemar (1947). Note on the sampling error of the difference between correlated proportions or percentages. Psychometrika 12(2).