Course contentsShow
← Data Science
Lesson 436 of 2,14511. Hypothesis Tests for Proportions and CategoriesFree lesson

Conducting McNemar's Test

Apply McNemar's Test to before-after data and interpret results for discordant pairs.

Conducting McNemar's Test

You'll learn how to perform McNemar's Test on before-after data and interpret the results based on discordant pairs.

The Core Idea

McNemar's Test focuses exclusively on the discordant pairs—cases where the before and after measurements differ. Imagine you're testing whether a training program changes people's opinion (Yes/No) on a topic. Some people switch from No to Yes, others from Yes to No, and many stay the same. McNemar's Test asks: "Among those who did change, is one direction significantly more common than the other?"

The Test Statistic

McNemar's statistic compares the two types of discordant pairs:

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

Where:

  • b = number who changed from "No" to "Yes" (discordant type 1)
  • c = number who changed from "Yes" to "No" (discordant type 2)

This follows a chi-squared distribution with 1 degree of freedom under the null hypothesis that both types of change are equally likely.

The Workflow

  1. Set up hypotheses: H₀: The probability of switching in either direction is equal
  2. Organize your 2×2 table and identify b and c (the off-diagonal counts)
  3. Calculate the test statistic using only b and c
  4. Find the p-value from the chi-squared distribution (df = 1)
  5. Interpret: If p < α, conclude that one direction of change is significantly more common

Continuity correction: For small counts (b + c < 25), use the corrected formula: χ² = (|b - c| - 1)² / (b + c)

Key Takeaway: McNemar's Test focuses only on the discordant pairs (b and c) to determine if one type of change is significantly more prevalent than the other in paired categorical data.