When the same subjects are measured twice on a yes-or-no outcome, the four possible outcomes are: yes both times, no both times, yes then no, and no then yes. McNemar's test looks at the last two and ignores the first two entirely. The reasoning is that a subject who converted under both conditions, or under neither, tells you nothing about which condition is better — they would have landed in the same place regardless, and including them only dilutes the comparison.
That makes it the binary counterpart of the paired t-test, and it inherits the same advantage. Between-subject variation is removed from the comparison, because each subject serves as their own control. A population where some people are eager converters and others never buy no longer swamps the signal, since the eager converters and the never-buyers both fall into the discarded agreement cells. What remains is only the people the treatment actually moved.
The discarding is what people find counterintuitive, and it is worth being precise about why it is correct rather than wasteful. Suppose 900 subjects convert under both conditions, 30 convert only under A, and 70 only under B. The question is whether B genuinely moves more people than A, and the evidence for that lives entirely in the 30 versus 70 split. The 900 are consistent with A and B being identical and equally consistent with B being far better; they simply do not discriminate. Adding them to the denominator would make the test less sensitive, not more honest.
Its natural home in experimentation is anywhere the same unit sees both conditions: interleaving experiments in search and recommendations, where one user is shown a blended result set and their click reveals a preference; before-and-after studies on a binary outcome; and diagnostic or model comparisons where two classifiers score the same set of cases. It is not applicable to a standard A/B test, where each user sees one variant and there is no second measurement to pair with.
The classical version uses a chi-square approximation with one degree of freedom, and it needs a reasonable number of discordant pairs — the usual guidance is at least 25. Below that the approximation is unreliable and the exact binomial version is the right choice, which is the same relationship Fisher's exact test has with chi-square on unpaired data. Note that the threshold applies to the discordant pairs alone, so a study with 5,000 subjects and 18 changers still needs the exact test.
Only two of the four cells appear anywhere in the arithmetic, which is the whole idea stated as a formula.
A search team runs an interleaving experiment on 4,200 sessions, showing each user results blended from two ranking models and recording which model produced the clicked result. In 3,540 sessions the click was ambiguous or both models would have surfaced the same item; 268 sessions favoured model A and 392 favoured model B.
- Total sessions
- 4,200
- Uninformative (concordant)
- 3,540
- Favoured model A (b)
- 268
- Favoured model B (c)
- 392
- Discordant pairs
- 660 — well above 25, so the chi-square form is fine
- Statistic
- (392 − 268)² / 660 = 23.30
p = 0.0000014 on one degree of freedom. Model B is preferred in 59.4% of the sessions that discriminated between the two.
The test rests on 660 sessions out of 4,200, and that is the design working rather than data being wasted. The other 3,540 sessions were genuinely uninformative about which model ranks better — both models would have produced the same click — so including them would have diluted a clear signal into a muddy one. Two cautions. The 59.4% preference is among discriminating sessions only, and translating it into a business impact needs the whole denominator: the difference across all sessions is (392 − 268) / 4,200, or 3.0 percentage points, which is the number a stakeholder should hear. And interleaving measures preference between two rankings, not whether either ranking increases revenue — a model users prefer click-for-click can still perform worse on the outcome the business cares about.
- דDiscarding the agreements throws away most of your data.”
- It discards the observations that cannot distinguish the two conditions. A subject who converted under both would have converted whichever they saw, so they contribute nothing to the question of which is better. Including them would shrink the apparent effect and reduce sensitivity — the exclusion makes the test more powerful, not less.
- דMcNemar's test can be used on any two proportions.”
- Only paired ones, where the same subjects generate both measurements. Applying it to two independent groups is a genuine error: the discordant-pair structure it depends on does not exist, and there is no principled way to build the b and c cells. Independent proportions need a z-test or a chi-square test.
- דA significant McNemar's test means the treatment works for most people.”
- It means more people moved in one direction than the other among those who moved at all. If 660 of 4,200 subjects were affected and B won 392 of those, the treatment changed the outcome for about 3% of the population. That can be a valuable effect and it is not the same claim as the 59% figure the discordant split suggests.