McNemar test
Compares a yes/no outcome measured twice in the same patients, or in matched pairs, using only the pairs that changed.
Clinical example
Whether the proportion of positive results differs between two screening tests applied to the same patients.
When to use it
- The outcome is yes or no and measured twice in the same patients, or in matched pairs.
- You want to compare the two proportions.
- You don't need to adjust for other variables.
Assumptions to check
Matched pairs
Each patient or matched pair appears once, and pairs are independent of each other.
What to report
- The paired table
- Both proportions, and how many patients changed in each direction
- The exact p-value, not just "p < 0.05"
Common mistakes
Paired data need a paired test
Measurements in the same patient are related. An unpaired test ignores that and loses power, or gives the wrong answer.
Alternatives
| If your situation is… | Use |
|---|---|
| Three or more measurements, or clustered patients | GEE and mixed-effects logistic regression |
In your software
# R
tab <- table(first = d$test_a, second = d$test_b)
mcnemar.test(tab)
CROSSTABS
/TABLES=test_a BY test_b
/STATISTICS=MCNEMAR
/CELLS=COUNT.
Sources
A confidence interval for the difference
The test gives a p-value. For a 95% confidence interval for the difference in paired proportions, a bootstrap confidence interval is one option: resample the patients (the pairs), recalculate the difference each time, and take the middle 95%.