# McNemar’s Test Calculator

URL: https://speedycalculator.com/calculators/statistics/mcnemars-test/
Last updated: 2026-10-30

> McNemar's test calculator checks whether paired yes/no outcomes changed – before vs after, or test A vs test B on the same subjects. It gives the chi-square statistic (plain, Edwards- or Yates-corrected) or the exact and mid-p binomial p-values, with the decision and the marginal proportions.

## Inputs

- Positive on both (a) — Test 1 / before: positive, Test 2 / after: positive
- Positive first, negative second (b)
- Negative first, positive second (c)
- Negative on both (d)
- Test version
- Significance level (α)

## Results

- p-value
- Test statistic χ²
- Degrees of freedom
- Decision
- Critical χ² (df = 1)
- Paired table with totals
- Discordant pairs (b + c)
- Proportion positive on test 1 / before
- Proportion positive on test 2 / after
- Difference in proportions (1 − 2)
- Paired odds ratio (b ÷ c)
- Null distribution of the test statistic

## Formula

```
χ² = (b − c)² ÷ (b + c) · Edwards: χ² = (|b − c| − 1)² ÷ (b + c) · Yates-type: (|b − c| − 0.5)² ÷ (b + c) · df = 1 · exact p = 2 × P(X ≤ min(b, c)), X ~ Binomial(b + c, 0.5) · mid-p = exact p − P(X = min(b, c))
```

## Explanation

McNemar's test is the paired counterpart of the chi-square test for 2×2 tables. It applies when the same subjects are classified twice on a yes/no outcome – symptoms before and after treatment, a voter's opinion before and after a debate, or two diagnostic tests applied to the same patients. Because the two measurements are linked, the ordinary chi-square test of independence is not valid.

Only the discordant pairs carry information about change. Cell b counts subjects who were positive the first time and negative the second, and cell c those who went the other way. If there is no real change in the overall proportion, b and c should be about equal; the test asks whether their difference is larger than chance would produce. Concordant pairs (a and d) do not enter the statistic at all.

With many discordant pairs, (b − c)² ÷ (b + c) follows a chi-square distribution with 1 degree of freedom. Edwards' continuity correction makes it more conservative. When b + c is below about 25, use the exact binomial version – or its mid-p variant, which is less conservative but still keeps close to the nominal α.

### How to use the McNemar's Test Calculator

- **Positive on both (a)** — Test 1 / before: positive, Test 2 / after: positive
- **Positive first, negative second (b)**
- **Negative first, positive second (c)**
- **Negative on both (d)**
- **Test version**
- **Significance level (α)**

Everything is calculated in your browser, so results appear instantly and nothing you type is sent to a server.

### How it works

Fill in the 2×2 table of paired results and pick the version of the test. The chi-square versions compare (|b − c| − correction)² ÷ (b + c) with a χ²(1) distribution; the binomial versions treat b as a binomial count out of b + c with p = 0.5.

### Worked example

161 patients are screened with an old and a new test. 59 are positive on both, 80 negative on both, 6 positive only on the old test (b) and 16 positive only on the new test (c).

Standard McNemar: χ² = (6 − 16)² ÷ 22 = 4.545 with 1 df, p = 0.033 – the new test flags more patients. With Edwards' correction χ² = 81 ÷ 22 = 3.682 and p = 0.055. Because b + c = 22 is small, the exact binomial p-value 2 × P(X ≤ 6 | n = 22, p = 0.5) = 0.052 is the safer choice, and the mid-p-value is 0.035.

The positive rate is 40.4% with the old test and 46.6% with the new one.

### Table layout

Test 2 / after: positiveTest 2 / after: negativeTest 1 / before: positiveabTest 1 / before: negativecd

## Worked example

Inputs — Positive on both (a): 59; Positive first, negative second (b): 6; Negative first, positive second (c): 16; Negative on both (d): 80; Test version: Standard McNemar's test (χ²); Significance level (α): 0.05.

Results — **p-value = 0.03**; Test statistic χ² = 4.5455; Degrees of freedom = 1; Decision = Reject H₀ (equal marginal proportions) at α = 0.05 – p = 0.033 ≤ 0.05.; Critical χ² (df = 1) = 3.8415; Paired table with totals = Test 2 + Test 2 − Total
──────────────────────────────────────
Test 1 + 59 6 65
Test 1 − 16 80 96
Total 75 86 161
b + c = 22 < 25: the exact binomial version is recommended..

## Key terms

- **Paired data**: Two measurements on the same subject or on matched subjects.
- **Discordant pairs**: Pairs whose two results disagree (cells b and c).
- **Marginal homogeneity**: The null hypothesis that the proportion positive is the same at both measurements.
- **Continuity correction**: An adjustment to |b − c| that makes the chi-square approximation closer to the exact discrete test.

## FAQ

**When should I use McNemar's test?**
For paired or matched yes/no data: the same people measured twice, matched case-control pairs, or two tests on the same samples.

**Why are cells a and d ignored?**
They are pairs where nothing changed. They tell you nothing about whether changes in one direction outnumber changes in the other.

**When should I use the exact version?**
When b + c is below 25. In the default example b + c = 22, and the exact p-value (0.052) differs noticeably from the chi-square p (0.033).

**What is the mid-p-value?**
The exact p-value minus half of the two-sided weight of the observed outcome. It is less conservative than the exact test and performs well in simulation studies.

**Can I use McNemar's test for more than two categories?**
Use the Stuart–Maxwell test (marginal homogeneity) for k × k tables, or Cochran's Q for more than two time points with a yes/no outcome.

**How do I report the result?**
Give b, c, the statistic and p: for example "χ²(1) = 4.55, p = 0.033" – and the two marginal proportions so readers see the size of the change.


## Sources

- [Wikipedia – McNemar's test](https://en.wikipedia.org/wiki/McNemar%27s_test)
- [NIST/SEMATECH e-Handbook of Statistical Methods](https://www.itl.nist.gov/div898/handbook/)
- [Penn State STAT 500 – Applied Statistics](https://online.stat.psu.edu/stat500/)
