McNemar Test Calculator
Enter a paired 2 × 2 table — the same people classified twice, before and after, or by two methods — and get McNemar's test three ways: the exact binomial p-value, χ² with Edwards's continuity correction, and χ² without it. You also get the paired odds ratio b / c with an exact confidence interval and the two proportions being compared. Free, no sign-up.
Rows are the first measurement, columns the second. Each count is a number of people (or pairs), so every person appears exactly once.
| Total | |||
|---|---|---|---|
| — | |||
| — | |||
| Total | — | — | — |
Fill all four cells with whole-number counts — zero is allowed.
How to Use the McNemar Test Calculator
- 1. Build the paired table. Rows are the first measurement and columns the second, so each person lands in exactly one of the four cells. The top-left cell counts those who said yes both times; the bottom-right, no both times.
- 2. Rename the rows and columns to match your study — before and after, rater A and rater B, or method 1 and method 2.
- 3. Choose the p-value to report. The exact binomial test is the safe default; the χ² versions are offered because many textbooks and journals still use them.
- 4. Read and report. All three p-values are shown side by side, with the odds ratio, its exact interval, the working, and an APA line.
Why Only the Changes Count
Label the cells a (yes, yes), b (yes, no), c (no, yes), and d (no, no). The proportion answering yes is (a + b)/N the first time and (a + c)/N the second, so the two proportions differ by (b − c)/N — the concordant cells a and d cancel out. McNemar's test therefore asks one question: among the b + c people who changed, did they change in one direction more often than the other? Under the null hypothesis each change is equally likely to go either way, so b follows a binomial distribution with n = b + c and probability ½.
- Exact test: p = 2 × P(X ≤ min(b, c)) for X ~ Binomial(b + c, ½), capped at 1. It is valid at any sample size.
- χ² without correction: χ² = (b − c)² / (b + c) with 1 degree of freedom (McNemar, 1947).
- χ² with Edwards's continuity correction: χ² = (|b − c| − 1)² / (b + c), the default in R's
mcnemar.test. It tracks the exact p-value more closely than the uncorrected version. - Paired odds ratio: b / c, with an exact interval from the Clopper–Pearson bounds for b / (b + c) converted to odds.
Worked Example: Opinions Before and After a Debate
Click Try an example to load 100 students asked whether they support a policy before and after a class debate. Thirty supported it both times and 50 opposed it both times; 15 switched from support to opposition, and 5 from opposition to support. Support fell from 45% to 35%.
McNemar's test, step by step
b = 15, c = 5, b + c = 20
exact: p = 2 × P(X ≤ 5), X ~ Binomial(20, ½) = 2 × .0207 = .0414
χ² (corrected) = (|15 − 5| − 1)² / 20 = 81 / 20 = 4.05, p = .044
χ² (uncorrected) = (15 − 5)² / 20 = 5.00, p = .025
OR = 15 / 5 = 3.00, 95% CI [1.04, 10.55]
In APA style: support for the policy fell from 45% to 35% after the debate, McNemar's test (exact binomial), p = .041, OR = 3.00, 95% CI [1.04, 10.55]. Students who changed their minds were three times as likely to move toward opposition as toward support. Notice how close the exact and corrected p-values are, and how much smaller the uncorrected one is — with 20 discordant pairs the uncorrected χ² overstates the evidence.
McNemar or Chi-Square?
Both use a 2 × 2 table, but they answer different questions. The chi-square test of independence needs independent observations — different people in every cell — and asks whether two variables are associated. Paired answers from the same people are not independent, and with before-and-after data they will almost always be associated (people who said yes before tend to say yes after), so the chi-square test answers a question nobody asked. McNemar's test asks whether the proportion changed, which is what paired designs are built to detect. For two independent groups, use the chi-square test, Fisher's exact test, or a two-proportion z-test instead.
Frequently Asked Questions
- What is McNemar's test used for?
- Comparing two proportions measured on the same subjects: the percentage answering yes before and after an intervention, the sensitivity of two diagnostic tests applied to the same patients, or two raters classifying the same items. It tests whether the proportion of yes answers differs between the two measurements.
- Why does McNemar's test ignore the people who did not change?
- Because they cannot tell you which way things moved. A person who answered yes both times adds the same amount to both proportions, so the difference between the proportions depends only on b and c, the two groups who changed. The concordant counts still matter for describing the proportions, which is why the calculator reports them.
- Should I use the exact or the chi-square version of McNemar's test?
- Use the exact binomial version when b + c is small — under about 25 — and whenever you want a p-value that is valid at any sample size. With many discordant pairs the corrected χ² and the exact test agree closely. The uncorrected χ² is the least conservative and overstates the evidence in small samples.
- How do I report McNemar's test in APA style?
- Give the two proportions, name the version of the test, and report the statistic or p-value with an effect size: McNemar's χ²(1, N = 100) = 4.05, p = .044, or for the exact version, McNemar's test (exact binomial), p = .041. Add the odds ratio with its interval, OR = 3.00, 95% CI [1.04, 10.55]. Italicise N, p, and OR.
- Can McNemar's test handle more than two categories?
- Not in this form. For a k × k table of paired classifications, the McNemar–Bowker test checks whether the table is symmetric, and the Stuart–Maxwell test checks whether the marginal distributions match. This calculator covers the 2 × 2 case.
- Is McNemar's test the same as Cohen's kappa?
- No. Both use a paired table, but kappa measures how much two raters agree beyond chance, while McNemar's test asks whether one rater says yes more often than the other. Two raters can agree well and still differ systematically, or agree poorly with no systematic difference — report both if both questions matter.