What Is the McNemar Test?
The McNemar test is a non-parametric statistical test for paired nominal (categorical) data with a dichotomous outcome. It was developed by American psychologist Quinn McNemar in 1947 and remains the standard method for testing whether the marginal proportions of a binary outcome change significantly between two related measurements.
The core question the McNemar test answers is: "Has the proportion of subjects with a positive outcome changed significantly between condition A and condition B?" The conditions might be two time points (before and after), two diagnostic tests applied to the same patient, or two matched individuals (a case and their paired control).
Crucially, the McNemar test focuses exclusively on the discordant pairs — subjects (or matched pairs) whose outcome status differs between the two conditions. Subjects who were positive on both measurements (concordant positive) or negative on both (concordant negative) do not change the marginal proportions and therefore contribute no information to the test. This elegant feature is what makes the McNemar test both powerful and statistically correct for paired designs.
When to Use the McNemar Test
The McNemar test is the appropriate choice whenever all three of the following conditions are met:
- The outcome variable is binary (dichotomous): yes/no, positive/negative, present/absent, cured/not cured, improved/not improved
- The data are paired: each observation in condition A is matched to a specific observation in condition B
- You want to test whether the proportions differ: not just whether categories differ, but whether the marginal probability of a positive outcome has changed
The Most Common Study Designs
- Before-after designs: The same patients are assessed before and after an intervention (surgery, drug, education programme). Outcome: were symptoms present before? After?
- Matched case-control studies: Each case is matched to a control on age, sex, and disease severity. Outcome: was the exposure (e.g., smoking) present in the case? In the matched control?
- Diagnostic agreement: Two tests (or two raters) classify the same patients as positive or negative. McNemar tests whether the two tests have equal positivity rates on the same subjects. (Note: for measuring agreement rather than marginal equality, use Cohen's Kappa instead.)
- Crossover trials: Each patient receives both treatments in different periods. Outcome: was the patient a responder under treatment A? Under treatment B?
Assumptions of the McNemar Test
The McNemar test has relatively few assumptions, which contributes to its robust applicability in clinical research:
- Binary outcome: The outcome variable must be dichotomous (two categories only). For three or more ordered categories, use the Stuart-Maxwell test (marginal homogeneity test) instead.
- Paired observations: Each subject (or matched pair) must contribute exactly one measurement to each condition. The pairing must be natural and pre-specified, not post-hoc.
- Random sampling: Subjects should be a representative sample (or a randomized cohort) from the population of interest. The McNemar test does not correct for selection bias.
- Large enough discordant pairs (for chi-square approximation): The standard McNemar chi-square statistic assumes that b + c ≥ 25 (where b and c are the two discordant cells). For smaller samples, use the exact binomial McNemar test.
The McNemar Formula and the 2×2 Table
Every McNemar analysis begins with constructing a 2×2 contingency table that cross-tabulates the outcome at condition A (rows) against the outcome at condition B (columns):
| Condition B: Positive | Condition B: Negative | Row Total | |
|---|---|---|---|
| Condition A: Positive | a (concordant +) | b (A+ → B−) | a + b |
| Condition A: Negative | c (A− → B+) | d (concordant −) | c + d |
| Column Total | a + c | b + d | n (total) |
Cells a and d are concordant pairs (no change in status). Cells b and c are the discordant pairs. Under the null hypothesis of marginal homogeneity, b and c should be approximately equal (each patient is equally likely to change in either direction by chance alone).
Valid when b + c ≥ 25
Exact Binomial McNemar Test
When b + c < 25, the chi-square approximation is unreliable. The exact test treats the number of "improvements" (c) as a binomial random variable with n = b + c trials and p = 0.5 under H₀. The two-tailed p-value is computed from the exact binomial distribution and reported directly by software (SPSS Exact Tests module, R's mcnemar.test(correct = FALSE), or Stata's mcci).
Effect Size: Odds Ratio for Discordant Pairs
The chi-square statistic from McNemar tells you whether the change is statistically significant, but not how large the effect is. The most interpretable effect size is the discordant-pair odds ratio: OR = b / c. An OR > 1 means that more subjects changed from negative to positive (improved) than from positive to negative (worsened). Report the OR with its 95% confidence interval alongside the McNemar statistic.
Clinical Examples
Step 1: Build the 2×2 table
| Post: H. pylori + | Post: H. pylori − | |
|---|---|---|
| Pre: H. pylori + | a = 8 (still positive) | b = 74 (positive → negative) |
| Pre: H. pylori − | c = 4 (negative → positive) | d = 34 (still negative) |
Step 1: Build the 2×2 table
| 3D: Recall | 3D: No Recall | |
|---|---|---|
| 2D: Recall | a = 22 (both recall) | b = 18 (2D+ only) |
| 2D: No Recall | c = 9 (3D+ only) | d = 151 (neither) |
Step 1: Build the 2×2 table
| Control: Exposed (GDM) | Control: Unexposed | |
|---|---|---|
| Case: Exposed (GDM) | a = 11 (both exposed) | b = 31 (case only exposed) |
| Case: Unexposed | c = 9 (control only exposed) | d = 34 (neither exposed) |
McNemar Test vs Chi-Square Test
The most common error in paired categorical data analysis is using the Chi-Square test when the McNemar test is required. Understanding why this matters prevents a very common and peer-review-rejected methodological mistake:
✓ McNemar Test (Correct for Paired Data)
- Accounts for within-subject correlation
- Tests only discordant pairs — where the real information lies
- Preserves correct Type I error rate (α = 0.05)
- Correct for matched case-control, before-after, crossover
- Every pair must come from the same subject or matched unit
✗ Chi-Square Test (Wrong for Paired Data)
- Assumes independence between all observations
- Treats each measurement as a separate subject
- Inflates Type I error (too many false positives)
- Correct only for independent groups (RCT arms, cohort groups)
- Mixing paired and Chi-Square is a reportable methodological flaw
Extensions of the McNemar Test
McNemar Test with Continuity Correction (Yates)
Some textbooks present a continuity-corrected version: χ² = (|b − c| − 1)² / (b + c). However, this correction is overly conservative and generally not recommended by modern biostatisticians. Use the exact binomial test when b + c < 25; use the uncorrected McNemar when b + c ≥ 25.
Stuart-Maxwell Test (Generalised McNemar)
For nominal or ordinal outcomes with three or more categories measured twice on the same subjects, the Stuart-Maxwell test (also called the marginal homogeneity test) generalises the McNemar framework to k×k tables. This is the correct method when your outcome is a Likert scale (strongly disagree to strongly agree), a disease severity grade (mild/moderate/severe), or any other multi-category variable measured at two time points.
McNemar-Bowker Test
The Bowker test extends McNemar to test symmetry in a square k×k table. While Stuart-Maxwell tests marginal homogeneity (the most common clinical question), Bowker tests complete symmetry (a stricter condition). Available in SPSS and R's DescTools package (BowkerTest()).
Thesis and Research Reporting Recommendations
When writing up the McNemar test in a thesis, dissertation, or journal manuscript, follow these evidence-based reporting practices:
State Your Design Explicitly
Before presenting the statistical results, clearly describe the paired structure of your data: "Each participant was assessed at baseline and at 12-week follow-up. Because the same patients contributed data at both time points, we used McNemar's test for paired dichotomous outcomes rather than the Chi-Square test, which assumes independence between groups."
Present the Full 2×2 Table
Always include the complete 2×2 table showing all four cells (a, b, c, d) in your results section. Reviewers and readers need to see both concordant and discordant cells to understand the data structure and verify your calculation. Label rows as "Baseline" and columns as "Follow-up" (or whichever conditions apply).
Report All Required Statistics
The elements to always include: marginal proportions at both time points (with denominators), the McNemar chi-square value, degrees of freedom (always 1), p-value, number of discordant pairs in each direction, and the effect size (OR with 95% CI).
Interpret the Clinical Meaning
Never end your results section with just a p-value. Translate the finding: state the direction of the change, the magnitude (odds ratio), and what this means for patients or clinical practice. A p < 0.001 tells the reader that the change is real; the odds ratio tells them how large it is.
Common Mistakes Researchers Make
Mistake 1: Using Chi-Square for Paired Data
The most frequent error: applying the Pearson Chi-Square test to before-after data from the same subjects, or to matched case-control data. The independence assumption is violated, the Type I error rate is inflated, and the paper will be flagged by competent peer reviewers.
Mistake 2: Reporting Only the P-Value Without Effect Size
The p-value alone does not indicate clinical importance. A study with 2,000 matched pairs might detect a trivially small change (e.g., from 50.1% to 49.9%) as highly significant (p < 0.001) because the test is very powerful at that sample size. The discordant-pair odds ratio contextualises the finding.
Mistake 3: Ignoring the Exact Test When Discordant Pairs Are Few
When b + c < 25, the chi-square approximation is unreliable. Researchers sometimes report a McNemar chi-square value even when only 8 or 12 discordant pairs are available, producing inaccurate p-values that cannot be trusted.
mcnemar.test(correct = FALSE)), or Stata.Mistake 4: Applying McNemar to Unpaired Data with Post-Hoc Matching
Some researchers collect independent groups and then retrospectively match subjects on confounders to "use the more powerful McNemar test." This is statistical manipulation: McNemar requires pre-specified pairing based on the study design, not post-hoc data reshuffling.
Mistake 5: Using McNemar for Continuous or Ordinal Data
The McNemar test is only valid for binary outcomes. Using it on a 5-point Likert scale (by arbitrarily dichotomising at a cutpoint) discards information and reduces power unnecessarily.
Mistake 6: Omitting the 2×2 Table From the Results Section
Reporting only the chi-square statistic and p-value without the full 2×2 table prevents readers from verifying the analysis and understanding the concordant-vs-discordant structure of the data — a significant transparency deficit.
Scientific Paper Reporting Recommendations
The following guidelines synthesise recommendations from APA 7th Edition, CONSORT 2010 (for RCTs), and STROBE (for observational studies):
- Methods section: State that the McNemar test was used for paired binary outcomes. Cite the original McNemar (1947) reference or a standard biostatistics textbook. Specify the significance threshold (α = 0.05) and whether continuity correction or exact test was used.
- Results section: Report frequencies and proportions at both time points, the McNemar χ²(1) value, p-value, the number of discordant pairs, and the odds ratio with 95% CI.
- Tables: Include the full 2×2 table with row and column totals. Label the table clearly ("McNemar 2×2 Table: Symptom Status Before and After Intervention").
- For exact tests: Note "McNemar's exact test" and report the exact two-tailed p-value from the binomial distribution.
Practical Tips for Medical Researchers
Plan for Discordant Pairs, Not Total N
Sample size calculations for McNemar are based on the expected number of discordant pairs (b + c), not the total sample size. You need to estimate what proportion of subjects will change status. A common mistake is planning for total N without considering that concordant pairs contribute nothing to the test.
Pre-Specify the Pairing Variable
In your study protocol and ethics application, document the exact pairing structure — whether it's temporal (same patient at two times), geographic (case and matched community control), or design-based (crossover sequence). Auditors and peer reviewers will ask.
Check for Missing Pairs Before Analysis
If a subject has data at baseline but not at follow-up (or vice versa), their pair is incomplete. The McNemar test can only use complete pairs. Document how many pairs were excluded due to missing data and perform a sensitivity analysis if the proportion excluded exceeds 10%.
Use Software for Exact P-Values
Manual calculation of the McNemar chi-square is straightforward, but exact p-values for small samples require software. In SPSS: Analyze → Nonparametric Tests → Legacy Dialogs → 2 Related Samples → McNemar. In R: mcnemar.test(matrix(c(a,b,c,d),2,2)).
Report Concordant Pairs for Transparency
Even though concordant pairs don't affect the McNemar statistic, report the counts in cells a and d. They inform the reader about the overall prevalence and the proportion of stable outcomes — important for understanding the clinical context.
Consider Stratified Analysis for Subgroups
If your study has pre-specified subgroups (e.g., males vs females, age <50 vs ≥50), run separate McNemar tests within each stratum. Do not combine subgroups and run a single analysis if the treatment effect plausibly differs between groups.
Frequently Asked Questions
pwr package in R and many online calculators can compute the required total N to achieve 80% power at α = 0.05.DescTools package.Run the McNemar Test Online
Use StatClinic's built-in McNemar calculator to analyse your paired categorical data instantly. Enter your 2×2 table, get the chi-square statistic, exact p-value, and discordant-pair odds ratio with confidence intervals — formatted for thesis and journal submission.
Open McNemar Calculator →