McNemar's Test Calculator
Perform McNemar's test for paired binomial data with chi-squared, Edwards, Yates, exact, and mid-p methods.
What Is McNemar's Test?
McNemar's test compares paired proportions from dichotomous outcomes, such as before-and-after results on the same subjects. Use it when each pair contributes one cell in a 2×2 table and you want to know whether the marginal proportions differ. Related tools include the Fisher's Exact Test Calculator and the Hypothesis Testing Calculator.
Contingency Table Layout
Label rows as Test 1 outcomes and columns as Test 2 outcomes:
- a: Test1+ and Test2+
- b: Test1+ and Test2− (discordant)
- c: Test1− and Test2+ (discordant)
- d: Test1− and Test2−
Only the discordant cells b and c enter the McNemar statistic. Concordant cells a and d do not change the test statistic.
Formulas
Standard McNemar chi-squared statistic:
$$\chi^2 = \frac{(b - c)^2}{b + c}$$
Edwards continuity correction:
$$\chi^2 = \frac{(|b - c| - 1)^2}{b + c}$$
Yates continuity correction:
$$\chi^2 = \frac{(|b - c| - 0.5)^2}{b + c}$$
For small samples ($b + c < 25$), prefer the exact binomial or mid-p versions. Under the null, the discordant count follows a binomial distribution with $p = 0.5$.
Example
With $a=60$, $b=70$, $c=50$, $d=40$:
$$\chi^2 = \frac{(70 - 50)^2}{70 + 50} = \frac{400}{120} \approx 3.333$$
The chi-squared p-value is about 0.068, so at $\alpha = 0.05$ you would not reject the null of equal marginal proportions.
Frequently Asked Questions
When should I use McNemar's test?
Use it for paired binary outcomes, such as pass/fail before and after a course, or positive/negative test results before and after treatment on the same people.
What is the null hypothesis?
The null says the two marginal proportions are equal, which simplifies to $p_b = p_c$. Rejecting it suggests the paired condition changes the proportion of positives.
When should I use the exact test?
Use the exact binomial (or mid-p) method when discordant pairs are few, typically when $b + c < 25$. The chi-squared approximation can be unreliable with sparse discordant counts.
Do cells a and d matter?
They affect totals and table display, but the McNemar statistic depends only on discordant cells b and c.
What is the mid-p correction?
The mid-p value subtracts half the probability mass of the observed outcome from the two-sided exact p-value. It is less conservative than the exact test while remaining useful for small samples.