01
McNemar's test formula
χ² = (b − c)² ÷ (b + c)
with continuity correction: χ² = (|b − c| − 1)² ÷ (b + c)
b and c are the two discordant cells: pairs that were yes then no, and no then yes. Pairs that gave the same answer both times carry no information about a change and are not used. The statistic has 1 degree of freedom.
02
Worked example
100 patients are tested before and after a treatment.
| After: yes | After: no | |
|---|---|---|
| Before: yes | 30 | 15 |
| Before: no | 5 | 50 |
χ² = (15 − 5)² ÷ 20 = 5.00, p = 0.0253
corrected: (10 − 1)² ÷ 20 = 4.05, p = 0.0442
With only 20 changed pairs the exact binomial test is preferred: p = 0.0414. The odds ratio is 15 ÷ 5 = 3.
03
Which test for which data
- Same subjects measured twice, yes/no outcome: McNemar's test.
- Two independent groups: the chi-square test or the two-proportion z test. Using those on paired data ignores the pairing and is wrong.
- Fewer than about 25 discordant pairs: report the exact binomial p value.
04
Common mistakes with paired proportions
- Ignoring the pairing. Treating the worked example as two independent groups (45 of 100 before, 35 of 100 after) gives a chi-square p of 0.149, against McNemar’s exact 0.041.
- Using the plain chi-square with few changed pairs. With 20 discordant pairs it gives p = 0.025; the exact binomial p is 0.041.
- Reporting the odds ratio from the margins. (45 ÷ 55) ÷ (35 ÷ 65) = 1.52 ignores who changed; the matched-pairs odds ratio is 15 ÷ 5 = 3.
Trust
How this page is checked
- The calculation runs on code with automated tests against worked reference values. Every number in the examples on this page was produced by that same code, not typed by hand.
- The formulas and conventions used are stated on the page, so you can reproduce the result yourself or compare it with your own software.
- Sources: McNemar (1947), Note on the sampling error of the difference between correlated proportions.
- Last reviewed by the Sciloom team, Zebra Nine Studio Inc. It is a tool for research and teaching, not a substitute for a statistician, a validated lab method or medical advice.
Cite this page
Sciloom. (2026). McNemar's test calculator. Zebra Nine Studio Inc. https://sciloom.si/mcnemar-test-calculator
Frequently asked questions
What is a discordant pair?
A pair whose two measurements differ: yes before and no after, or the reverse. McNemar's test asks whether the two kinds of change are equally common.
Should I use the continuity correction?
It makes the chi-square approximation more conservative with small counts. With few discordant pairs, skip the debate and use the exact p value.
Why are the concordant cells ignored?
Under the null hypothesis a change in either direction is equally likely, and that can be judged from the changed pairs alone. The unchanged pairs affect the size of the difference in proportions but not the test.
What is the matched odds ratio?
b divided by c. It estimates the odds ratio for paired data, such as a matched case-control study.