McNemar's Test Calculator

Statistical test for paired categorical data with 2×2 contingency tables

2×2 Contingency Table

After: Positive
After: Negative
Row Total
Before: Positive
0
Before: Negative
0
Column Total
0
0
N = 0

Enter the observed frequencies for each cell of the 2×2 contingency table

Choose appropriate test method

Example Calculation

Medical Treatment Study

Scenario: 220 patients tested before and after treatment

Data: a=60, b=70, c=50, d=40

Question: Does treatment significantly affect test results?

Calculation

χ² = (b-c)²/(b+c) = (70-50)²/(70+50) = 400/120 = 3.33

p-value = 1 - χ²cdf(3.33) = 0.068

Decision: p-value (0.068) > α (0.05), not significant

Conclusion: No evidence that treatment affects test results

Test Selection Guide

Standard McNemar's

Use when b+c ≥ 25

Exact Binomial

Use when b+c < 25

Edwards Correction

Conservative correction

Mid-p Test

Less conservative than exact

Contingency Table

Cell Definitions:

a: Positive before, Positive after

b: Negative before, Positive after

c: Positive before, Negative after

d: Negative before, Negative after

Key Focus:

McNemar's test uses only discordant pairs (b + c)

Formulas

Standard McNemar's:

χ² = (b-c)²/(b+c)

Edwards Correction:

χ² = (|b-c|-1)²/(b+c)

Yates Correction:

χ² = (|b-c|-0.5)²/(b+c)

Understanding McNemar's Test

What is McNemar's Test?

McNemar's test is a statistical test used for paired categorical data to determine whether the marginal proportions differ significantly between two related groups or time points.

When to Use McNemar's Test

  • Before-after treatment comparisons
  • Matched pairs with binary outcomes
  • Test-retest reliability studies
  • Comparing two diagnostic methods

Key Assumptions

Paired Data

Each subject must be measured twice (e.g., before and after treatment).

Binary Outcome

The outcome variable must have exactly two categories (e.g., pass/fail, positive/negative).

Independence

Different pairs should be independent of each other.

Important Notes

  • • McNemar's test focuses only on discordant pairs (cells b and c)
  • • Use exact test when b+c < 25 for better accuracy
  • • The test assumes the changes are symmetric under the null hypothesis
  • • Not appropriate for independent groups (use Chi-square test instead)