Significance test

McNemar's Test Calculator

McNemar's test checks whether a paired binary outcome changed — the same subjects measured twice (before/after) or matched pairs. Only the two discordant cells matter: it tests whether b and c differ using χ² = (b − c)²/(b + c) with df = 1, or an exact binomial test for small samples.

Reviewed by the crosstabs.com methods team · Last updated

Run this on your own data — free, no signup

Upload a CSV or XLSX. Everything runs in your browser; your file never leaves your device.

Open the workspace →

Calculate online

Fill in the paired 2×2 table — each subject is counted once according to its before/after pair. The concordant cells a and d (no change) do not affect the test; only the highlighted discordant cells b and c do.

Paired 2×2 table — each subject is counted once, by its (Before, After) pair. The highlighted discordant cells b and c are the only ones that enter the test.

After
BeforePositiveNegativeTotal
Positive74
Negative26
Total6436100

a = +/+   b = +/−   c = −/+   d = −/−   (Before/After)

McNemar's test (continuity-corrected)

4.05

df = 1 · p = .044 · 20 discordant pairs

χ²(1, N = 100) = 4.05, p = .044

McNemar χ² (uncorrected)χ² = 5.000, df = 1, p = .025
With continuity correction (Edwards)χ² = 4.050, df = 1, p = .044
Exact binomial test (two-sided)p = .041
Only 20 discordant pairs — with fewer than ~25, prefer the exact binomial p-value over the chi-square approximation.

Why ordinary chi-square is wrong for paired data

The chi-square test of independence assumes every observation is independent — two different groups of people, one count each. In a before/after design the same person appears in both measurements, so the observations are correlated and the independence test gives the wrong answer to the wrong question.

McNemar's insight is that the subjects who didn't change (cells a and d) carry no information about change. Under the null hypothesis of no shift, each changer is equally likely to move in either direction, so b and c should be about equal — and that is exactly what the test checks. Not sure which design you have? See which statistical test should I use.

Formula

Definition

χ² = (b − c)² / (b + c), df = 1

b
= subjects positive before but negative after (one direction of change)
c
= subjects negative before but positive after (the other direction)
(|b − c| − 1)²/(b + c)
= the Edwards continuity-corrected version, recommended for moderate samples
exact p
= a two-sided binomial test of b successes in b + c trials at p = ½ — preferred when b + c is small (under ~25)

Worked example

Worked example

100 voters are asked whether they support a policy before and after a debate. 59 supported it both times (a), 21 opposed it both times (d), 15 switched from support to oppose (b), and 5 switched from oppose to support (c).

Only the 20 switchers matter: χ² = (15 − 5)² / 20 = 5.00 (p = .025); with continuity correction, (|15 − 5| − 1)² / 20 = 4.05 (p = .044); the exact binomial p-value is p = .041.

All three agree the shift is significant — opinion moved against the policy after the debate.

When to use it

Use it when

  • The same subjects are measured twice on a binary outcome (before/after, test/retest).
  • Matched case-control pairs with a yes/no exposure.
  • You want to know whether the proportion changed, not whether two variables are associated.

Not the right tool when

  • The two samples are independent groups — use the ordinary chi-square test or Fisher's exact test instead.
  • The outcome has more than two categories — use the Stuart–Maxwell test.
  • More than two repeated measurements — use Cochran's Q.

How to interpret it

Rule of thumb

A significant McNemar p-value (p < 0.05) means the change was asymmetric — more subjects moved in one direction than the other. With fewer than ~25 discordant pairs, report the exact binomial p-value rather than the chi-square approximation.

Run McNemar from Claude or any MCP client

The free crosstabs MCP server (pip install crosstabs) also exposes McNemar's test — including the exact variant — so Claude and other AI assistants can run it on your paired data with exact arithmetic instead of estimating.

Frequently asked questions

McNemar's test vs chi-square test of independence?
The chi-square test of independence compares two independent groups; McNemar's test compares paired measurements of the same subjects. If each person appears in both the 'before' and 'after' counts, the observations are correlated and you need McNemar — the ordinary chi-square would be invalid.
Why do only cells b and c matter?
Cells a and d count subjects whose answer did not change, which says nothing about the direction of change. Under the null hypothesis that change is equally likely in both directions, the b + c switchers split 50/50 between b and c — McNemar's test simply tests that split.
When should I use the exact p-value?
When the number of discordant pairs (b + c) is small — under about 25 — the chi-square approximation is unreliable, and the exact two-sided binomial test of b successes in b + c trials at p = 0.5 should be reported instead. For larger samples the corrected chi-square and the exact test essentially agree.
What is the continuity correction?
Edwards' correction replaces (b − c)² with (|b − c| − 1)², compensating for approximating a discrete count with a continuous chi-square distribution. It makes the test slightly more conservative and is the version most software reports by default.

References & further reading

  • McNemar, Q. (1947). Note on the sampling error of the difference between correlated proportions or percentages. 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.
  • McNemar's test — Wikipedia

Try it on your own data — free, no signup

Upload a CSV or XLSX. Everything runs in your browser; your file never leaves your device.

Open the workspace →

Related calculators

← All calculators & guides