What Is McNemar's Test?
McNemar's test is a hypothesis test that checks whether a yes/no proportion changed between 2 measurements on the same subjects.
Typical questions include "Did more people support the product after the ad campaign?" and "Do two diagnostic tests detect the condition equally often in the same patients?". Quinn McNemar published the test in Psychometrika in 1947. Tests on paired means live in the Z Test Calculator suite.
Setting Up the Paired 2×2 Table
A paired 2 × 2 table counts subjects by their answer at time 1 and their answer at time 2.
| After: yes | After: no | |
|---|---|---|
| Before: yes | a (no change) | b (yes → no) |
| Before: no | c (no → yes) | d (no change) |
Cells a and d are concordant pairs. Cells b and c are discordant pairs, the subjects who changed.
McNemar Test Formula (Discordant Pairs b and c)
McNemar's test uses only the discordant pairs: χ² = (b − c)² / (b + c), with 1 degree of freedom. Under H₀, changes in each direction are equally likely, so b and c should be close.
With Continuity Correction
Edwards' continuity correction subtracts 1 from |b − c|: χ² = (|b − c| − 1)² / (b + c). Allen L. Edwards proposed the correction in 1948. The corrected statistic makes the χ² approximation closer to the exact result.
Exact McNemar Test for Small Samples
The exact McNemar test treats b as a binomial count out of b + c with p = 0.5. The two-sided p-value is 2 × P(X ≤ min(b, c)). Use the exact version when b + c is below 25.
Assumptions of McNemar's Test
McNemar's test needs 3 assumptions:
- Paired data: each subject (or matched pair) gives 2 yes/no answers.
- Independent pairs: one subject does not influence another.
- Enough discordant pairs for the χ² version: b + c ≥ 25, otherwise use the exact test.
How to Use the McNemar Test Calculator
To use the McNemar test calculator, follow 3 steps:
- Enter the 4 cells of the paired table (a, b, c, d).
- Choose Edwards' correction or no correction.
- Set α.
The paired table highlights the discordant cells, the balance bar compares b with c against an even split and the χ² curve marks the statistic. The cards show the χ² p-value and the exact binomial p-value side by side.
Interpreting McNemar Test Results
A significant McNemar test means the yes rate changed between the two measurements. The direction comes from comparing b and c: c > b means more subjects switched from no to yes. The odds ratio b / c measures the size of the imbalance, and (c − b) / N gives the change in the yes proportion.
McNemar Test Examples
There are 2 worked examples below.
Example 1: Opinion Before and After an Ad Campaign
100 people: 45 said yes both times, 15 switched yes → no, 5 switched no → yes and 35 said no both times.
- Discordant pairsb = 15, c = 5, b + c = 20
- Chi-square (corrected)χ² = (|15 − 5| − 1)² / 20 = 4.05
- P-valuep = 0.0442
- Exact p-value0.0414
- DecisionReject H₀: support changed, with more people switching away from yes.
Example 2: Comparing Two Diagnostic Tests
100 patients take tests A and B: 40 positive on both, 12 positive on A only, 4 positive on B only, 44 negative on both.
- Discordant pairsb = 12, c = 4
- Chi-square (corrected)χ² = (|12 − 4| − 1)² / 16 = 3.06
- P-valuep = 0.0801
- Exact p-value0.0768
- DecisionFail to reject H₀ at α = 0.05: the tests do not differ in positive rate.
McNemar vs. Chi-Square Test
Use McNemar's test for paired yes/no data, and the chi-square test of independence for two independent groups. Running a chi-square test on paired data ignores the pairing and gives the wrong p-value. Analyse independent groups with the chi square calculator.
FAQs
Why are the concordant pairs ignored?
Concordant pairs are ignored, since subjects who gave the same answer twice carry no information about change. Only b and c differ under H₀ and H₁. Adding 1,000 subjects who said yes twice leaves the test unchanged.
What if b + c is smaller than 25?
Use the exact McNemar test when b + c is smaller than 25. The exact test is a binomial test on b out of b + c with p = 0.5. Run the same calculation with the binomial test calculator.
Can McNemar's test handle more than two categories?
No, McNemar's test handles 2 categories; the Stuart–Maxwell test extends it to 3 or more. Cochran's Q test extends McNemar's test to 3 or more paired yes/no measurements.
How is McNemar's test different from a paired z-test?
McNemar's test analyses paired yes/no outcomes, while the paired z-test analyses paired numeric measurements. Use the paired z test for scores, weights or times measured twice.
How do I report McNemar's test in APA format?
Report McNemar's test as χ²(1, N = total) = value, p = value, with the discordant counts. Example: "Support fell after the campaign (15 switched to no, 5 to yes), McNemar χ²(1, N = 100) = 4.05, p = .044." To compare two separate groups instead, use the two proportion z test calculator.