McNemar's Test Calculator
Test cases replayed : 3 of 3 match · Methodology · No outside source listed
Enter the two discordant counts of a paired 2 × 2 table (pairs that changed in one direction or the other) to test whether the change is significant.
Result
p-value (chi-square, 1 df)
McNemar chi-square, (b − c)² ÷ (b + c)
- Chi-square with continuity correction
- p-value with continuity correction
- Exact two-sided p-value (binomial)
Estimate for planning only, not tax, legal, financial or medical advice. This calculator uses the method explained on this page.
This browser did not allow copying. The sentence is in the box below, already selected: copy it with your keyboard or the menu.
How to use this calculator
Fill in the fields in this order; each step takes you to its field.
- Pairs positive before and negative after (b): enter 0 or more.
- Pairs negative before and positive after (c): enter 0 or more.
- Read the result: p-value (chi-square, 1 df); the panel also shows McNemar chi-square, (b − c)² ÷ (b + c), Chi-square with continuity correction, p-value with continuity correction and Exact two-sided p-value (binomial).
How this calculator works
McNemar's test (Psychometrika, 1947) compares two paired proportions, for example the same people before and after, or two tests on the same subjects. Only the discordant pairs matter: b changed one way and c the other.
Statistic χ² = (b − c)² ÷ (b + c), compared with a chi-square distribution with 1 degree of freedom. Edwards' continuity correction uses (|b − c| − 1)² ÷ (b + c). When b + c is small (under about 25), the exact test is preferred: two-sided p = 2 × P(X ≤ min(b, c)) for X binomial with n = b + c and p = 0.5, capped at 1.
The formula
| Symbol | Meaning |
|---|---|
| Pairs positive before and negative after | |
| Pairs negative before and positive after | |
| McNemar chi-square, (b − c)² ÷ (b + c) | |
| p-value (chi-square, 1 df) | |
chi2cdf(x, k) | the probability that a chi-square variable with k degrees of freedom is at most x. |
Worked example
| Pairs positive before and negative after (b) | 15 |
|---|---|
| Pairs negative before and positive after (c) | 5 |
| McNemar chi-square, (b − c)² ÷ (b + c) | 5 |
|---|---|
| Chi-square with continuity correction | 4.05 |
| p-value with continuity correction | 0.0442 |
| Exact two-sided p-value (binomial) | 0.0414 |
p-value (chi-square, 1 df) 0.0253
Each step uses the unrounded value of the step before it; figures on this page are rounded for display.
Frequently asked questions
Why are the concordant pairs not used?
Pairs that gave the same answer both times carry no information about a change; under the null hypothesis, changes in each direction are equally likely.
Is b = 15 and c = 5 significant?
χ² = 100 ÷ 20 = 5, p ≈ 0.0253 at the 5% level; with the continuity correction p ≈ 0.0442, and the exact test gives p ≈ 0.0414.