CHAPTER 05 · TOPIC 07
McNemar’s Test
Analyze discordant pairs in paired binary data to compare directional change probabilities and marginal proportions.
On this page
The McNemar test tests whether marginal proportions are equal in paired binary data, such as before and after measurements of the same subject or matched pairs. Unlike a regular 2x2 independence test, only the unmatched pairs that have changed results are informative.
Paired 2×2 Table#
| Measurement 1\Measurement 2 | positive | negative |
| positive | a: Positive → Positive | b: Positive → Negative |
| negative | c: Negative → positive | d: Negative → negative |
a and d are unchanged matched pairs. b and c are mismatched pairs that change in opposite directions, and H₀ asserts that these two directions occur to the same extent.
Hypothesis and conditional binomial distribution#
Derivation of the Z Statistic#
McNemar chi-square statistic#
For a two-sided test, you can use χ², which is Z squared. The larger the difference between b and c compared to the total number of mismatched pairs, the more contrary to H₀ that the marginal ratios are equal.
Exact McNemar test#
If b+c is small, use B~Binomial(b+c,1/2) directly. Since it is a discrete distribution, specify the definition of a two-sided p value and whether to use mid-p.
Continuity correction#
If you subtract 0.5 on the binomial scale of b, you subtract 1 on the b - c difference scale. Although the correction is more conservative, the exact binomial method is more direct for small numbers of discrepancies.
Difference with independence test#
| item | Pearson independence test | McNemar test |
| data | Two binary variables from independent observations | Binary results with matched and repeated measurements |
| H₀ | two variables are independent | The two discordant transition probabilities, or marginal proportions, are equal |
| Cell to use | all cells | Mismatched cells b, c |
| large sample statistics | Σ(O−E)²/E | (b−c)²/(b+c) |
Implementation and reporting procedures#
- Check the definition of pairs and encoding of binary results
- Make a, b, c, d and check especially the number of discrepancies b+c
- Preset H₀, bilateral/unilateral, α
- If the number of discrepancies is sufficient, select uncorrected or corrected χ², if small, select exact binomial method.
- b and c, report proportions, changes, p-values, and usage for each time point
- Consider the impact of missing data and dropped pairs on the results