McNemar Test Calculator
Statistical tests
- Discordant pairs: 28 pairs changed one way and 9 the other; the 37 concordant-free pairs are the only ones McNemar uses.
- Continuity correction: (|28 - 9| - 1)^2 / 37 = 8.76, the Edwards correction that keeps the chi-square approximation honest.
- Without the correction the statistic would be 9.76, and the matched odds ratio is 28 / 9 = 3.11.
- McNemar result: chi-square 8.76 on 1 degree of freedom, tested against 3.84 at the 5% level.
Before-and-after studies ask a deceptively simple question: did people change? A training programme tests 200 workers, 60 pass afterwards who failed before, 25 fail afterwards who passed before, and 115 do not move. McNemar's test, from 1947, is built on the realisation that only the changers carry evidence — the 115 who stayed put say nothing about direction.
The two discordant counts are conventionally called b, pairs that switched one way, and c, pairs that switched the other. The statistic is (b - c)^2 / (b + c), chi-square on 1 degree of freedom, and Edwards' continuity correction — subtracting 1 from the absolute difference before squaring — is the version most software reports and the headline figure here.
Enter b and c. Alongside the corrected statistic you get the uncorrected value and the matched odds ratio b/c, the effect size that should accompany any report of the test.
Worked examples
McNemar test of a diagnostic comparison
(28 · 9)
| McNemar chi-square (corrected) | 8.76 |
| Uncorrected chi-square | 9.76 |
| Odds ratio b/c | 3.11 |
McNemar test of a guideline comparison
(14 · 21)
| McNemar chi-square (corrected) | 1.03 |
| Uncorrected chi-square | 1.40 |
| Odds ratio b/c | 0.67 |
McNemar test of a reader study
(45 · 12)
| McNemar chi-square (corrected) | 17.96 |
| Uncorrected chi-square | 19.11 |
| Odds ratio b/c | 3.75 |
Pairs, not people
The paired design is what gives McNemar its power and its constraints. Each subject serves as their own control, so stable differences between people cancel out of the comparison entirely. The price is that the test sees only the discordant cells of the 2x2 table; a study where almost nobody changes needs enormous samples to detect anything, because its effective n is b + c, not the headcount.
In the first worked example, 28 pairs switched one way and 9 the other. The corrected statistic is (28 - 9 - 1)^2 / 37 = 8.76, comfortably past the 3.84 critical value at 5 percent. The matched odds ratio of 3.11 says changers were about three times as likely to move in the b direction as the c direction.
| Quantity | Formula | Role |
|---|---|---|
| Corrected chi-square | (|b - c| - 1)^2 / (b + c) | Headline test statistic |
| Uncorrected chi-square | (b - c)^2 / (b + c) | Shown for comparison |
| Matched odds ratio | b / c | Effect size |
| Critical value, 5% | 3.84 | Chi-square, 1 degree of freedom |
The continuity correction
The chi-square distribution is continuous; the discordant counts are not. With small b + c the uncorrected statistic systematically overstates significance, and Edwards' correction compensates by shrinking the difference by one pair before squaring. In the reversed second example — 14 against 21 — the correction pulls the statistic from 1.40 down to 1.03, though with a difference that small no version approaches significance.
Modern practice splits the difference: use the corrected chi-square for moderate discordant counts, and switch to the exact binomial test — a sign test on the discordant pairs — when b + c falls under about 25. The exact test needs no approximation and is the safer report at small counts, at the price of conservatism from the discrete distribution.
- Only discordant pairs enter; concordant pairs affect neither the statistic nor its power calculations beyond design.
- Keep b and c definitions consistent — swapping them inverts the odds ratio but not the chi-square.
- Below about 25 discordant pairs, prefer the exact binomial (sign) test.
- The test detects change, not its cause; paired observational data still confound.
- Report the odds ratio b/c with the statistic so readers see the effect's size and direction.
Worked examples
Example 1: Discordant pairs b (yes then no) 28; Discordant pairs c (no then yes) 9. McNemar chi-square (corrected) = 8.76. Supporting values: Uncorrected chi-square 9.76; Odds ratio b/c 3.11. Discordant pairs: 28 pairs changed one way and 9 the other; the 37 concordant-free pairs are the only ones McNemar uses. Continuity correction: (|28 - 9| - 1)^2 / 37 = 8.76, the Edwards correction that keeps the chi-square approximation honest. Without the correction the statistic would be 9.76, and the matched odds ratio is 28 / 9 = 3.11. McNemar result: chi-square 8.76 on 1 degree of freedom, tested against 3.84 at the 5% level.
Example 2: Discordant pairs b (yes then no) 14; Discordant pairs c (no then yes) 21. McNemar chi-square (corrected) = 1.03. Supporting values: Uncorrected chi-square 1.40; Odds ratio b/c 0.67. Discordant pairs: 14 pairs changed one way and 21 the other; the 35 concordant-free pairs are the only ones McNemar uses. Continuity correction: (|14 - 21| - 1)^2 / 35 = 1.03, the Edwards correction that keeps the chi-square approximation honest. Without the correction the statistic would be 1.40, and the matched odds ratio is 14 / 21 = 0.67. McNemar result: chi-square 1.03 on 1 degree of freedom, tested against 3.84 at the 5% level.
Example 3: Discordant pairs b (yes then no) 45; Discordant pairs c (no then yes) 12. McNemar chi-square (corrected) = 17.96. Supporting values: Uncorrected chi-square 19.11; Odds ratio b/c 3.75. Discordant pairs: 45 pairs changed one way and 12 the other; the 57 concordant-free pairs are the only ones McNemar uses. Continuity correction: (|45 - 12| - 1)^2 / 57 = 17.96, the Edwards correction that keeps the chi-square approximation honest. Without the correction the statistic would be 19.11, and the matched odds ratio is 45 / 12 = 3.75. McNemar result: chi-square 17.96 on 1 degree of freedom, tested against 3.84 at the 5% level.
Designs that break the test
McNemar assumes the pairs are genuinely paired — the same subjects twice, or matches made before outcomes were known. Applying it to two independent groups that merely have the same size is a category error; that comparison belongs to the ordinary chi-square or Fisher test, and using McNemar there fabricates precision from a pairing that does not exist.
It also assumes the outcome is truly binary. Collapsing a five-point scale into pass/fail to fit the test throws away the gradations where most change happens; the Wilcoxon signed-rank test or a Stuart-Maxwell test respects ordinal or multi-category paired data better. Choose the dichotomy because the science is dichotomous, not because the formula is convenient.
McNemar in practice
The test appears wherever paired binary outcomes arise: diagnostic tests compared on the same patients, where McNemar isolates the cases the two tests disagree on; marketing tests on matched stores; and clinical crossover snapshots. The diagnostic use is the most instructive — two scans can agree on 95 percent of patients while McNemar, reading only the disagreements, shows one systematically catching cases the other misses.
The strongest worked example, 45 against 12 for a corrected 17.96 and an odds ratio of 3.75, is that pattern at full strength: overwhelming directional evidence carried by a minority of the pairs.
McNemar in diagnostic accuracy studies
The test's most consequential modern use is comparing two diagnostic tests applied to the same patients. Sensitivity comparisons are McNemar problems in disguise: among patients with the disease, the two tests agree on most, and only the discordant pairs — one test catching what the other missed — carry evidence about which sensitivity is higher. Studies that instead compare the two sensitivities with an unpaired test on the full counts throw away the pairing and, with it, most of their power.
The same structure governs specificity among the disease-free, and paired reader studies in radiology, where two radiologists score the same films. In each case the reportable quantities are the ones this page prints: the discordant counts themselves, the corrected statistic, and the odds ratio, which in the diagnostic setting reads as the odds that a disagreement favours one test over the other.
A design corollary follows that young researchers often miss: the sample size calculation for such a study must be built on the expected number of discordant pairs, not the total enrolment. A trial of a thousand patients expecting 4 percent discordance is a McNemar study of forty pairs, and should be powered — and budgeted — as one.
The continuity correction itself has a history worth a paragraph. Yates proposed the device in 1934 for 2x2 tables generally; Edwards applied it to McNemar's statistic in 1948, and the pairing stuck so firmly that 'McNemar with continuity correction' became the default in statistical packages for seventy years. Modern simulation work is less reverent: at moderate discordant counts the correction is roughly right, at large counts it merely costs a little power, and at small counts the exact test supersedes both versions. Knowing which regime you are in — the examples here sit at 37, 35 and 57 discordant pairs, squarely in the correction's home territory — is the difference between using a default and understanding one.
FAQs
What corrected chi-square does the first example give?
8.76, from 28 pairs against 9: (28 - 9 - 1) squared over 37.
What uncorrected statistic pairs with it?
9.76 — the continuity correction costs about a point of chi-square at this sample size.
What odds ratio results in the first example?
3.11, the ratio 28/9 of the two discordant counts.
What corrected chi-square does the reversed example give?
1.03 from 14 against 21 — nowhere near the 3.84 critical value.
When should the exact test replace McNemar?
When discordant pairs b + c fall below roughly 25, where the chi-square approximation becomes unreliable.
What corrected chi-square does the strongest example reach?
17.96, from 45 against 12 discordant pairs, with an odds ratio of 3.75.