McNemar's Test Calculator

Statistics

McNemar's Test Calculator

Test for paired nominal data using 2×2 contingency tables. Ideal for before/after studies and matched pairs.

2×2 Contingency Table

Enter counts for paired categorical outcomes:

After +
After −
Before +
Before −

Results

χ² (with continuity correction)
4.0500
χ² (no correction)
5.0000
Z-score
2.2361
p-value (corrected)
0.002668
p-value (uncorrected)
0.000904
Discordant b
5
Discordant c
15
Odds Ratio (b/c)
0.3333
Total n
100
✓ Significant at α = 0.05
Evidence of change between before and after.

What is McNemar's Test?

McNemar's test is a statistical test for paired nominal data (binary outcomes). It determines if a change occurs between two related observations within the same subjects.

Hypothesis: H₀: No change between paired observations | H₁: Change detected

The 2×2 Contingency Table:

  • a: Before +, After + (concordant — no change)
  • b: Before +, After − (discordant — changed to negative)
  • c: Before −, After + (discordant — changed to positive)
  • d: Before −, After − (concordant — no change)

Key Insight: McNemar's test ignores concordant pairs (a and d) and focuses only on discordant pairs (b and c). If there's no change, b and c should be roughly equal.

When to Use: Paired categorical data, before/after studies, matched case-control, repeated measurements on the same subjects.

How to Perform McNemar's Test

1

Construct 2×2 table

Count observations in all four cells. Rows = Before outcome, Columns = After outcome.

2

Identify discordant cells

Extract b (Before +, After −) and c (Before −, After +). Ignore a and d.

3

Calculate χ² with continuity correction

χ² = (|b − c| − 1)² / (b + c). This asymptotically follows chi-square distribution with df = 1.

4

Convert to z-score

z = √χ². For large samples, use standard normal distribution; z-table gives p-value.

5

Two-tailed p-value

p = 2 × P(Z ≥ |z|). Compare to α = 0.05 for significance testing.

Example Calculation

Study: Testing a new smoking cessation program 80 smokers' status recorded before and after treatment 2x2 Table: After Quit After Still Smoke Before Quit 20 5 (b=5: quit before, smoking after) Before Smoke 15 60 (c=15: smoking before, quit after) Discordant pairs: b = 5, c = 15 chi2 = (|5 - 15| - 1)^2 / (5 + 15) = (10 - 1)^2 / 20 = 81 / 20 = 4.05 z = sqrt(4.05) ~= 2.012 p-value (two-tailed) ~= 0.044 Result: p = 0.044 (Significant at a = 0.05) Interpretation: The program significantly increased smoking cessation. More people quit (c=15) than relapsed back to smoking (b=5).

Frequently Asked Questions

Related Tools