Skip to content
K Knidox Search…
Statistics · Nonparametric

McNemar’s Test

Test whether paired yes/no answers changed — chi-square with the exact binomial alternative.

Concordant — does not affect the test.
Discordant pair.
Discordant pair.
Concordant — does not affect the test.
McNemar χ²
5.042χ²(1)p < .05

Based on the 24 discordant pairs (b = 18, c = 6) out of 100 total. Concordant pairs carry no information about change.

p-value
0.0247

Chi-square with 1 degree of freedom, continuity-corrected.

Exact binomial p
0.0227Prefer this

With only 24 discordant pairs the chi-square approximation is unreliable — report the exact test instead.

McNemar’s test uses only the pairs that changed. With 18 switching from yes to no and 6 from no to yes, the continuity-corrected chi-square is (|18 − 6| − 1)² ÷ 24 = 5.04 on 1 degree of freedom, giving p = .025 — a significant shift.

Why the agreements are discarded

McNemar’s test is for paired binary data: the same people measured twice, or matched cases and controls. The question is whether the proportion answering yes changed between the two occasions.

Participants who answered the same way both times carry no information about change. Someone who said yes before and yes after tells you nothing about the direction of any shift — only the discordant pairs do. So the test looks solely at the two off-diagonal cells: how many switched one way against how many switched the other. If the intervention did nothing, those two counts should be roughly equal.

Why a chi-square test is not the right tool here

A standard chi-square test of independence assumes the two samples are independent, which is exactly what paired data are not. Applying it to before-and-after data on the same people ignores the pairing and generally understates the evidence for change. McNemar’s test exists precisely to handle that dependence.

χ² = (b − c)² ÷ (b + c) With continuity correction: χ² = (|b − c| − 1)² ÷ (b + c) df = 1

b and c are the two discordant counts — those who changed in each direction. The concordant cells a and d do not appear in the formula at all.

Worked example: 30 / 18 / 6 / 46

Count the switchers, then test whether the two directions are balanced:

  1. 1
    Build the paired 2×2 table. Yes both times = 30, yes then no = 18, no then yes = 6, no both times = 46. Total N = 100.
  2. 2
    Identify the discordant pairs. b = 18 and c = 6, so 24 of the 100 participants changed their answer.
  3. 3
    Take the difference. 18 − 6 = 12. If the intervention had no effect, this should be near zero.
  4. 4
    Apply the corrected formula. (|12| − 1)² ÷ 24 = 121 ÷ 24 = 5.04.
  5. 5
    Find the p-value. A chi-square of 5.04 with 1 degree of freedom gives p = .025.
  6. 6
    Check the exact test. With 24 discordant pairs the exact binomial gives p = .023 — the two agree closely here.

Which test for which design

The distinction is whether the two sets of observations come from the same units.

DataTest
Paired binary, two occasionsMcNemar’s test
Paired binary, three or more occasionsCochran’s Q
Independent binary groupsChi-square or Fisher’s exact
Paired continuous or ordinalWilcoxon signed-rank
Paired binary agreement, not changeCohen’s kappa

The continuity correction and the exact test

Yates’ continuity correction subtracts 1 before squaring, compensating for using a continuous chi-square distribution to approximate discrete counts. It makes the test more conservative. Opinion is genuinely divided: the correction is standard in many textbooks, while others consider it over-cautious. Stating which you used is what matters.

The argument becomes moot when the number of discordant pairs is small. Below about 25, the chi-square approximation is unreliable in either form and the exact binomial test should be reported instead — it treats the b discordant switches as draws from a binomial with p = 0.5 and computes the probability directly, with no approximation involved.

One design point: a large total sample does not rescue a small discordant count. A study of 500 people in which only 9 changed their answer is a 9-pair test, and its power is set by that 9, not by the 500.

Why are the agreeing pairs ignored?
Because they carry no information about change. Someone who answered yes on both occasions cannot indicate a direction of shift, so only the discordant cells enter the calculation.
Can I use a normal chi-square test instead?
No. A chi-square test of independence assumes the two samples are independent, which paired data are not. Ignoring the pairing generally understates the evidence for a change.
Should I apply the continuity correction?
Practice is divided. The correction makes the test more conservative and is standard in many textbooks, while others regard it as over-cautious. Either is defensible provided you state which you used.
When should I use the exact binomial test?
When there are fewer than roughly 25 discordant pairs. Below that the chi-square approximation is unreliable, whereas the exact test computes the probability directly with no approximation.
Does a large sample make the test reliable?
Not on its own. Power depends on the number of discordant pairs, so a study of 500 people where only 9 changed is effectively a 9-pair test regardless of the total.
What if I have three or more time points?
Cochran’s Q extends McNemar’s test to more than two occasions on the same binary outcome, and reduces to McNemar’s test when there are exactly two.
How do I report the result?
Give the chi-square with its single degree of freedom, the exact p, the two discordant counts, and the total N — for example “χ²(1) = 5.04, p = .025, b = 18, c = 6, N = 100”.