McNemar's Test Calculator
Test for paired categorical data.
2Γ2 Table for Paired Data
b and c are the discordant pairs (changes between conditions)
Enter the 2Γ2 contingency table values
Use McNemar's test when you measure the same people twice with a yes/no outcome and want to know if the proportion changed. Common scenarios include testing whether opinions shifted after an event, whether a treatment changed someone's status from positive to negative (or vice versa), or whether matched pairs of subjects differ in some binary characteristic. It's the paired-data equivalent of comparing two proportions.
What Is McNemar's Test?
McNemar's test compares paired proportionsβspecifically for before-after designs or matched pairs with binary outcomes.
Question answered: "Did the proportion change from before to after?" or "Do matched pairs show different response rates?"
Examples:
- Did the proportion of voters supporting a candidate change after a debate?
- Do patients test positive at different rates before vs. after treatment?
- In matched case-control pairs, is exposure more common in cases?
The 2Γ2 Table for Paired Data
Unlike chi-square (which compares independent groups), McNemar's uses paired observations:
| After: Yes | After: No | |
|---|---|---|
| Before: Yes | a | b |
| Before: No | c | d |
- a: Yes both times (concordant)
- d: No both times (concordant)
- b: Changed from Yes to No (discordant)
- c: Changed from No to Yes (discordant)
The test focuses only on discordant pairs (b and c).
The Test Statistic
Standard McNemar Test
Follows chi-square distribution with 1 degree of freedom.
With Continuity Correction (Edwards)
Recommended when expected frequencies are small.
Exact Test (Small Samples)
When , use exact binomial test:
Under null hypothesis,
Example Calculation
Scenario: 100 voters surveyed before and after a debate.
| After: Support | After: Oppose | |
|---|---|---|
| Before: Support | 40 | 10 |
| Before: Oppose | 25 | 25 |
- a = 40 (supported both times)
- b = 10 (switched from support to oppose)
- c = 25 (switched from oppose to support)
- d = 25 (opposed both times)
Discordant pairs: b + c = 35
Test statistic:
P-value: For with df = 1:
Conclusion: Significant change in support (). Support increased (more switched to support than away from it).
Interpretation
Significant Result
The proportion changed between conditions (or cases differ from controls in matched pairs).
Direction: Compare b vs c
- If c > b: Proportion increased
- If b > c: Proportion decreased
Non-Significant Result
No evidence of change in proportion.
Confidence Interval for Difference
The difference in proportions:
Standard error:
95% CI:
From example:
- Proportion change: (25 - 10)/100 = 0.15 (15% increase)
- SE β 0.056
- 95% CI: [0.04, 0.26]
Odds Ratio for Matched Pairs
From example: OR = 25/10 = 2.5
Interpretation: "Voters were 2.5 times more likely to switch to support than away from support."
Confidence Interval for OR
Applications
Medical Research
Treatment response:
| After: Symptom-Free | After: Symptoms | |
|---|---|---|
| Before: Symptom-Free | 5 | 3 |
| Before: Symptoms | 42 | 50 |
Did treatment reduce symptoms? Test on b = 3, c = 42.
Matched Case-Control Studies
Exposure in matched pairs:
| Control: Exposed | Control: Not Exposed | |
|---|---|---|
| Case: Exposed | 20 | 35 |
| Case: Not Exposed | 10 | 35 |
Is exposure more common in cases? OR = 35/10 = 3.5.
Survey Research
Opinion change:
Pre-post surveys where the same individuals are measured twice.
Diagnostic Testing
Agreement between tests:
| Test B: Positive | Test B: Negative | |
|---|---|---|
| Test A: Positive | 45 | 5 |
| Test A: Negative | 15 | 35 |
Do the tests have different positive rates? Focus on discordant pairs.
Exact McNemar Test
For small samples (b + c < 25), use exact binomial test:
Or use statistical software for the exact p-value.
McNemar-Bowker Test (Extensions)
For tables larger than 2Γ2 (multiple categories), the McNemar-Bowker test of symmetry extends the concept.
Tests whether for all pairs of categories.
Assumptions
Paired/Matched Data
Each observation in "before" corresponds to exactly one observation in "after."
Binary Outcome
The outcome variable has exactly two categories.
Independent Pairs
Different pairs are independent of each other.
Random Sampling
Pairs are randomly selected from the population.
Common Mistakes
Using Chi-Square Instead
Standard chi-square test treats data as independent. For paired data, you must use McNemar's test.
Including Concordant Pairs
Only discordant pairs (b and c) contribute information. Concordant pairs (a and d) don't affect the test.
Small Sample Without Exact Test
When b + c < 25, the chi-square approximation is poor. Use exact test.
Confusing Direction
b = "changed from yes to no" and c = "changed from no to yes." Be clear about which is which.
Comparison with Related Tests
| Test | Use Case |
|---|---|
| McNemar's | Paired binary data |
| Chi-square | Independent binary data |
| Cochran's Q | Multiple paired binary measurements |
| Sign test | Paired ordinal/continuous data |
| Paired t-test | Paired continuous data |
Effect Size
Odds Ratio
| OR | Interpretation |
|---|---|
| 1 | No difference |
| 2-3 | Moderate effect |
| > 3 | Large effect |
Difference in Proportions
Directly interpretable as percentage point change.
Reporting Results
APA format:
"McNemar's test indicated a significant increase in support for the candidate after the debate, ΟΒ²(1) = 6.43, p = .011. Support increased by 15 percentage points (95% CI [4%, 26%]), with an odds ratio of 2.5 for switching to support versus switching away."
Historical Context
Quinn McNemar introduced this test in 1947 for psychological research involving before-after measurements on the same subjects.
The test filled an important gapβresearchers needed a way to analyze paired categorical data that respects the dependence structure.
Related Calculations
- Chi-Square Test β For independent groups
- Fisher's Exact Test β Exact test for independent groups
- Sign Test β For paired ordinal data
- Paired T-Test β For paired continuous data
Summary
McNemar's test compares paired binary outcomes, focusing on discordant pairs where the response changed. Calculate where b and c are the discordant pair counts. Use exact test for small samples (b + c < 25). Report the chi-square statistic, p-value, proportion difference with confidence interval, and odds ratio. The test is essential for before-after studies and matched case-control designs with binary outcomes.