Skip to content

McNemar Test

Test whether a paired binary outcome changed in a consistent direction, such as whether subjects who initially answered "no" were more likely to switch to "yes" than the reverse.

Only the two discordant cells matter for this test: subjects whose answer changed one way (b) versus the other way (c). Subjects whose answer stayed the same in both measurements carry no information here and are not needed as inputs.

What this answers

This test answers "among subjects whose paired binary outcome changed at all, was the change more common in one direction than the other?" It is the paired-data counterpart to the Two-Proportion z-Test, built specifically for before-and-after or matched binary outcomes on the same subjects, not independent groups.

How it is calculated

Only subjects whose outcome differs between the two measurements matter: cell b (positive in the first measurement, negative in the second) and cell c (the reverse). Subjects who answered the same way both times are concordant and drop out of the test entirely, since they provide no information about a directional change. When the discordant total (b plus c) is small (25 or fewer by default), this calculator uses the exact binomial test on the smaller of b and c against a fair-coin null; for larger discordant totals, it uses the continuity-corrected chi-square approximation instead.

Worked example

For b equal to 10 and c equal to 0 (every single discordant subject moved the same direction, none moved the other way), the discordant total is 10, well within the exact threshold. The exact two-sided p-value is 2 divided by 1,024, an extremely strong result reflecting that all 10 discordant subjects agreed on direction, the most extreme possible outcome for this sample size.

Assumption audit

Calculated from your data: the discordant total, whether the exact or chi-square mode was used based on that total, and the resulting p-value.
Evidence to review: how large the discordant total is; with very few discordant pairs, even a perfectly one-sided result may not reach conventional significance, simply from limited sample size.
You must verify: that each row genuinely represents the same subject measured twice (or a matched pair), and that b and c were correctly identified as the two discordant directions, not accidentally swapped or including concordant subjects.

What this result does not mean

A significant McNemar test means the direction of change among subjects who changed at all was not evenly split, not that a large fraction of all subjects changed; a small discordant total relative to the total sample can still be significant if it is heavily one-sided.

Limitations

This test uses only the two discordant cells and discards all information from concordant subjects, which is correct for this specific question but means it cannot detect anything about subjects who did not change. Do not use this test for two independent groups; that design belongs with the Two-Proportion z-Test instead.