McNemar's test calculator

This McNemar's test calculator compares two proportions measured on the same subjects: before and after, two tests on one sample, or matched cases and controls. Enter the paired 2 × 2 table to get the chi-square statistic, the exact p value and the odds ratio.

The numbers are calculated in your browser. Nothing you enter is sent or stored.

McNemar's test calculatorOr describe it in Studio →
After: yesAfter: no
Before: yes
Before: no

Each count is a number of pairs: the same person measured twice, or a matched case and control. Only the two outlined cells, the pairs that changed, enter the test.

The proportion changed significantly (p = 0.0414, exact).

Pairs that changed
20 (15 and 5)
Chi-square (1 df)
5, p = 0.0253
With continuity correction
4.05, p = 0.0442
Exact binomial p
0.0414
Before, after
45%, 35%
Difference (95% CI)
10 points (1.5 to 18.5)
Odds ratio (b ÷ c)
3

With fewer than 25 changed pairs the exact p is the one to report; above that the corrected chi-square is standard.

To report

McNemar's exact test, b = 15, c = 5, p = 0.0414

Check your result: only the changed pairs matter: the result must not move if you alter the 30 and 50 pairs that gave the same answer both times. b + c is the number of changed pairs (20) and the odds ratio is b ÷ c (15 ÷ 5 = 3).
exact p in the worked example
0.0414
exact p in the worked example
matched-pairs odds ratio
3
matched-pairs odds ratio
largest number of changed pairs
100,000
largest number of changed pairs
p values: chi-square, corrected and exact
3
p values: chi-square, corrected and exact
  • Chi-square, with and without correction
  • Exact binomial p value
  • Matched-pairs odds ratio
  • Says which p to report
  • Runs in your browser, free

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.

07.815145%test statistic
A right-tail p value. Statistics such as chi-square, F and H can only be zero or positive, and larger values mean a worse fit to the null hypothesis. The p value is the area to the right of your statistic. The curve shown has 3 degrees of freedom; 5% of its area lies beyond 7.815.

02

Worked example

100 patients are tested before and after a treatment.

After: yesAfter: no
Before: yes3015
Before: no550

χ² = (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

Read the full methodology · Who makes Sciloom

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.

Two separate groups rather than pairs? Use the two-proportion z test.
Free to start, no sign-up.
Back to the tool ↑

More research tools