Statistical Concepts

McNemar's Test: Paired Nominal Data Analysis

6 min read

Learn what McNemar's test is, how it handles before-after designs with categorical data, and when to use it instead of chi-square in paired research.

What Is McNemar's Test?

McNemar's test is a statistical test for paired nominal (categorical) data, used to determine whether the proportion of cases in one category changed between two related conditions. It's most commonly applied in before-after designs where the same participants provide binary responses (yes/no, agree/disagree, aware/not aware) at two time points. Unlike the chi-square test of independence, which compares independent groups. McNemar's test accounts for the paired structure of the data by focusing on discordant pairs: cases where the response changed from one condition to the other. If roughly equal numbers of people switch in each direction, the proportions haven't changed. If switching is asymmetric, McNemar's test detects the shift. It's named after Quinn McNemar, who introduced it in 1947.

Why McNemar's Test Matters

Before-after comparisons with categorical outcomes are everywhere in market research, tracking brand awareness before and after a campaign, measuring purchase intent before and after a product demo, or testing attitude change pre- and post-exposure to messaging. Using a standard chi-square test on paired data ignores the dependency between measurements and can produce wrong conclusions. McNemar's test is specifically designed for this paired structure and gives you a valid answer.

How McNemar's Test Works

The 2×2 Table

The data is organized into a 2×2 contingency table based on each participant's response at both time points:

After: Yes After: No
Before: Yes a (Yes→Yes) b (Yes→No)
Before: No c (No→Yes) d (No→No)

Cells a and d are concordant pairs, no change. Cells b and c are discordant pairs, the response changed. McNemar's test only uses the discordant cells.

The Formula

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

With 1 degree of freedom. Some versions include a continuity correction:

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

The continuity correction is recommended when b + c < 25.

Worked Example

You survey 200 customers about brand awareness before and after an ad campaign:

After: Aware After: Not Aware
Before: Aware 95 (a) 15 (b)
Before: Not Aware 40 (c) 50 (d)

Concordant: 95 + 50 = 145 (no change) Discordant: 15 switched from aware to not aware; 40 switched from not aware to aware.

χ² = (15 - 40)² / (15 + 40) = (-25)² / 55 = 625 / 55 = 11.36

With df = 1, the critical chi-square at α = 0.05 is 3.84. Since 11.36 > 3.84, the change in awareness is statistically significant (p < 0.001).

Interpretation: Significantly more people became aware (40) than lost awareness (15) after the campaign. The net gain of 25 aware customers (out of 55 who changed) is unlikely due to chance.

Before the campaign: 95 + 15 = 110 aware (55%). After: 95 + 40 = 135 aware (67.5%). The 12.5 percentage-point increase is statistically significant.

Exact McNemar's Test

When the total number of discordant pairs (b + c) is small (under 25), the chi-square approximation is unreliable. Use the exact binomial test instead, which tests whether the number of changes in one direction follows a binomial distribution with p = 0.5. Most statistical software provides this automatically.

McNemar's Test vs. Chi-Square Test

Feature McNemar's Test Chi-Square Test
Data structure Paired/matched Independent groups
Compares Change within subjects Proportions between groups
Uses Discordant pairs only All cells
Design Before-after, matched pairs Cross-sectional, between-group
Assumption Fixed marginals not required Expected frequencies ≥ 5

Extensions

  • McNemar-Bowker test: Extends McNemar's to variables with more than two categories (e.g., 3×3 or 4×4 tables of paired responses)
  • Cochran's Q test: Extends McNemar's to three or more related conditions with binary outcomes, the categorical equivalent of the Friedman test

When to Use McNemar's Test

  • Pre-post campaign measurement to test whether awareness, preference, or intent changed after exposure to advertising or messaging
  • Before-after product trials where participants report binary outcomes (would buy/wouldn't buy) before and after trying a product
  • Matched case-control studies comparing binary outcomes between matched pairs
  • Longitudinal surveys tracking the same respondents' binary responses at two time points
  • A/B preference testing where each participant chooses between two options at two different times

Common Mistakes to Avoid

  • Using chi-square on paired data: the standard chi-square test assumes independence between the two measurements, which is violated in before-after or matched-pair designs
  • Ignoring small discordant cell counts: when b + c < 25, use the exact binomial version rather than the chi-square approximation
  • Reporting only the after-proportions: the value of McNemar's test is in quantifying the change; report both before and after proportions along with the net shift

How Quali-Fi Supports Paired Categorical Analysis

Quali-Fi's Research plan ($1,061/month) includes McNemar's test for pre-post tracking studies with binary outcomes, automatically detecting the paired structure and reporting both the test result and the direction of change. For multi-wave studies with more than two time points, the platform extends to Cochran's Q test.

Track changes over time with Quali-Fi

Frequently Asked Questions

What's the minimum sample size for McNemar's test?

The key isn't total sample size, it's the number of discordant pairs (b + c). You need enough people who actually changed their response. With fewer than 25 discordant pairs, use the exact binomial version. For adequate power to detect a moderate asymmetry, aim for at least 30-50 discordant pairs.

Can McNemar's test handle ordinal data?

No. McNemar's test is for nominal (categorical) data with two levels. For paired ordinal data (like Likert scales), use the Wilcoxon signed-rank test. For paired ordinal data with more than two categories, use the marginal homogeneity test or Stuart-Maxwell test.

What if my categories have more than two levels?

Use the McNemar-Bowker test of symmetry for paired data with three or more nominal categories. It tests whether the off-diagonal cells in the k×k table are symmetric, meaning the pattern of change is equal in both directions across all category pairs.

Frequently Asked Questions

Related Guides

Put it into practice

Ready to apply this in your research?

Quali-Fi makes it easy to run surveys, conjoint studies, and more, all in one platform.