McNemar’s test
McNemar’s test compares paired binary outcomes by counting pairs that change in opposite directions.
Fit
When to use it, and when not to
Use it when
- Each person has two binary outcomes, or observations form prespecified matched pairs.
- You ask whether the two marginal probabilities are equal.
Not when
- The groups contain different, unmatched people. Use an independent categorical test. Read: Choosing a test for a table of counts
- You want to measure agreement rather than change. Use an agreement statistic. Read: Bland-Altman method comparison
- There are several visits or adjustment factors. Use an appropriate repeated binary-outcome model. Read: Generalized estimating equations
Before you start
What you need
- Counts for all four paired outcome combinationsLabel both time points or conditions. Distinguish the two discordant directions.
- The test variant chosen in advanceExact conditional, asymptotic and mid-p versions have different small-sample properties.
- The number and reasons for incomplete pairsMissing pairs may differ from complete pairs. State the missing-data assumption.
- Separate pairs are independent.How to check: Shared wards or several pairs from one person require a more suitable model.
- Each paired outcome has the same two defined categories.How to check: Use consistent thresholds at both measurements.
- Under the null, the two discordant directions are equally likely.How to check: Conditioning on the discordant total gives an exact binomial test with probability one half.
Plain language
How it works
Arrange each pair by its two outcomes. Concordant pairs have the same outcome both times; discordant pairs change. The null gives the two discordant directions equal probability. The exact conditional variant uses a binomial distribution for their split.
Fagerland and colleagues compare test variants and paired-proportion intervals. Exact conditional p-values can be conservative. Report the chosen variant and a paired effect estimate with an interval; do not substitute independent-proportion intervals.
Worked example
A worked example
- Setting
- A clinic records a binary symptom before and after care in 100 complete pairs.
- Question
- Did the marginal symptom probability change?
- Approach
- Both positive: 30; positive to negative: 17; negative to positive: 3; both negative: 50.
- Result
- There are 20 discordant pairs. The exact conditional two-sided p = 0.002577. Symptom counts change from 47 to 33, a difference of -14 per 100.
- What it means
- This is evidence of marginal change, not proof the care caused it. The exact conditional test can be conservative.
In practice
Recent studies PubMed search · not vetted
Watch out
Common mistakes
The one to remember
McNemar’s test uses discordant pairs. It tests marginal change, not agreement or causation; independent-group chi-square and Fisher tests discard the pairing.
- Using all pairs as the binomial denominator.Instead: Only the two discordant cells determine the McNemar test statistic.
- Treating a nonsignificant result as proof of agreement.Instead: Equal marginal rates can coexist with many discordant pairs.
Inside Mallard
How Mallard uses this
Mallard has no dedicated McNemar calculator. The method registry links this method to its published analysis article and code.
mcnemar-paired-binary).analysis.mcnemar, the id a plan cue records.Related Learn pages
Related designs and methods
Evidence
Sources & further reading
- The McNemar test for binary matched-pairs data: mid-p and asymptotic are better than exact conditional (opens in a new tab) · BMC Med Res Methodol · doi 10.1186/1471-2288-13-91
- Recommended tests and confidence intervals for paired binomial proportions (opens in a new tab) · Stat Med · doi 10.1002/sim.6148