About the McNemar Test Calculator
This McNemar test calculator checks whether a yes/no outcome changed between two paired measurements. Enter the four counts of the paired 2×2 table — subjects positive both times, positive then negative, negative then positive, and negative both times — and it returns the McNemar chi-square statistic, the p-value by your chosen method, the exact binomial p-value, the odds ratio of the discordant pairs and the change in the proportion positive with a 95% confidence interval.
Use it for before/after designs with a binary outcome (did a campaign change voting intention? did training change pass/fail results?), for matched case-control pairs, and for comparing two diagnostic tests or classifiers applied to the same subjects. It is the paired counterpart of the chi-square test of independence, which would be wrong here because the two measurements on the same subject are not independent.
Only the discordant pairs — the subjects who changed — carry information about change, so the test is driven by those two cells. With fewer than about 25 discordant pairs, the exact binomial (or mid-p) version is recommended over the chi-square approximation.
With the default inputs, the p-value (selected method) is 0.0801. Change any value above to recalculate instantly.
How to use the mcnemar test calculator
- 1Count subjects positive at both times (a) and negative at both times (d).
- 2Count those who switched from positive to negative (b) and from negative to positive (c).
- 3Enter the four counts and choose a p-value method — exact when b + c is small.
- 4Read the p-value and decision, then the change in proportion and its confidence interval.
Formula and method
In a paired 2×2 table, cells a and d are subjects whose outcome did not change and carry no information about change. Under the null hypothesis that the proportion positive is the same at both times (marginal homogeneity), a subject who changes is equally likely to change in either direction, so b should be close to c. The McNemar statistic compares them and follows a chi-square distribution with one degree of freedom when b + c is large.
Edwards’ continuity correction subtracts 1 from |b − c| to make the chi-square approximation more conservative. The exact test treats b as a Binomial(b + c, ½) count and doubles the smaller tail; the mid-p version subtracts the probability of the observed value once, which keeps the error rate close to α without being as conservative. The change in proportion is (b − c)/n with the Wald standard error √(b + c − (b − c)²/n) / n.
- a, d
- Concordant pairs (same result both times)
- b
- Pairs positive at time 1 and negative at time 2
- c
- Pairs negative at time 1 and positive at time 2
- n
- Total number of pairs, a + b + c + d
Worked examples
Exam pass/fail before and after a revision course
Of 100 students, 12 passed before but failed after (b) and 4 failed before but passed after (c). With continuity correction χ² = (|12 − 4| − 1)² ÷ 16 = 3.06 and p ≈ 0.080, so the change is not significant at 5%. Only 16 pairs are discordant, so the exact p ≈ 0.077 tells the same story.
Approval rating in two surveys of the same 1,600 people
In this classic textbook example, 150 people switched from approve to disapprove and 86 the other way. The uncorrected χ² = 64² ÷ 236 ≈ 17.36 with p ≈ 0.00003, and approval fell by 4 percentage points (95% CI 2.1 to 5.9 points).
Two diagnostic tests on the same 60 patients (exact test)
Test A was positive and test B negative for 9 patients, the reverse for 2. With only 11 discordant pairs the exact binomial test gives p = 2 × P(X ≤ 2 | 11, ½) ≈ 0.065, while the less conservative mid-p value is about 0.039.
Frequently asked questions
When should I use McNemar’s test?+
Use it when the same subjects (or matched pairs) are classified twice on a yes/no outcome — before and after an intervention, by two raters or tests, or in matched case-control studies — and you want to know whether the proportion of “yes” changed.
Why does McNemar’s test ignore cells a and d?+
Subjects who gave the same answer both times contribute equally to both proportions, so they cancel out of the difference. Only the discordant pairs b and c tell you whether change happened more in one direction.
Should I use the continuity correction or the exact test?+
With fewer than about 25 discordant pairs, use the exact binomial test (or the mid-p version, which is less conservative). With many discordant pairs, the chi-square test with or without correction gives nearly the same answer.
What is the difference between McNemar’s test and the chi-square test?+
The ordinary chi-square test assumes the two variables come from independent observations. McNemar’s test is for paired data where each subject is measured twice, so it tests marginal homogeneity rather than independence.
What does the paired odds ratio b/c mean?+
It is the ratio of the two kinds of change. An odds ratio of 3 means positive-to-negative switches were three times as common as negative-to-positive switches among subjects who changed.