McNemar’s test answers one question about paired yes/no data: when the same subjects are judged twice, does one judging say yes more often than the other? Two reviewers on the same applications, two diagnostic tests on the same patients, one model before and after retraining on the same cases: any time each row of your data carries two binary verdicts about the same thing, this is the paired-proportions question.
It is a test of marginal homogeneity, not of agreement. That distinction is the whole reason this method needs a video: two judges can agree on most cases and still be systematically biased in the cases where they differ. Agreement statistics look at how often the judges match. McNemar looks only at the disagreements, and asks whether they lean one way.
| Field | The question McNemar answers |
|---|---|
| Diagnostic testing | Do two tests, run on the same patients, differ in positive rate? (Trajman & Luiz 2008: compare sensitivities among the diseased) |
| Machine learning | Do two classifiers, scored on the same test set, differ in error rate? |
| Review pipelines | Do two reviewers approve at different rates on the same queue? |
| Clinical trials | Did a binary outcome change from before to after treatment in the same subjects? |
| Matched-pair A/B | Do matched units respond differently under two conditions? |
One table, one row per subject or case, with two binary verdicts per row: the same cases judged by both sources. That pairing is not a detail. It is the design fact that decides which test is legal.
The paired verdicts collapse into a 2x2 table with named cells:
both-yes, both-no, and the two kinds of disagreement. Write the
disagreements as b (first judge yes, second no) and
c (first no, second yes). The test statistic uses
only b and c:
\[\chi^2 = \frac{(b - c)^2}{b + c}\]
The concordant cells never enter the statistic. That is the mechanism behind the video’s central fact: agreement can be high while the test is decisive, because they are computed from different cells.
One honesty requirement the literature is blunt about: name your variant. The same 2x2 table yields different p-values under the uncorrected chi-square, the Edwards continuity correction, the exact binomial, and the mid-p test, and software defaults diverge three ways (R corrects by default, statsmodels is exact by default, SPSS switches to the exact form at small discordant counts, customarily below 25). Fagerland, Lydersen & Laake (2013) compared them: their recommendation is the mid-p (or the exact unconditional test), with the uncorrected asymptotic acceptable when small violations of the nominal level are tolerable. Of the exact conditional and continuity-corrected tests jointly they write that they “did not perform well for any of the considered scenarios”, and of the corrected version specifically, “we do not recommend that it is used.”
Two reviewers decide approve or deny on the same 200
applications. The dataset is synthetic and fully reproducible:
generated by mcnemar_example.py (seed 42) with cell counts
fixed by design, because we want the ground truth visible: 120
both-approve, 50 both-deny, 6 approved only by reviewer A, 24 approved
only by reviewer B.
d <- read.csv("cases.csv")
head(d)
## case_id reviewer_a reviewer_b
## 1 case_001 approve approve
## 2 case_002 deny approve
## 3 case_003 approve approve
## 4 case_004 deny approve
## 5 case_005 approve approve
## 6 case_006 deny deny
tab <- table(A = d$reviewer_a, B = d$reviewer_b)
tab
## B
## A approve deny
## approve 120 6
## deny 24 50
agreement <- (tab["approve", "approve"] + tab["deny", "deny"]) / sum(tab)
pa <- sum(tab["approve", ]) / sum(tab) # reviewer A approval rate
pb <- sum(tab[, "approve"]) / sum(tab) # reviewer B approval rate
pe <- pa * pb + (1 - pa) * (1 - pb)
kappa <- (agreement - pe) / (1 - pe)
round(c(agreement = agreement, kappa = kappa, rate_A = pa, rate_B = pb), 3)
## agreement kappa rate_A rate_B
## 0.850 0.661 0.630 0.720
Agreement 0.85 and kappa 0.66: numbers most dashboards would wave through. But the approval rates already hint at the story: reviewer B approves 9 percentage points more of the same queue.
Thirty cases got different verdicts, and they are lopsided: reviewer B approved 24 cases that A denied, while A approved only 6 cases that B denied. McNemar’s test asks whether a 24-to-6 split could be chance if neither reviewer were systematically more generous.
mcnemar.test(tab, correct = FALSE) # the evidence-preferred headline
##
## McNemar's Chi-squared test
##
## data: tab
## McNemar's chi-squared = 10.8, df = 1, p-value = 0.001015
mcnemar.test(tab) # R's default applies the Edwards correction
##
## McNemar's Chi-squared test with continuity correction
##
## data: tab
## McNemar's chi-squared = 9.6333, df = 1, p-value = 0.001911
b <- tab["approve", "deny"]; c <- tab["deny", "approve"]
c(exact_p = 2 * pbinom(min(b, c), b + c, 0.5),
mid_p = 2 * pbinom(min(b, c), b + c, 0.5) - dbinom(min(b, c), b + c, 0.5))
## exact_p mid_p
## 0.0014309064 0.0008779103
Every variant agrees the split is real (all p < 0.002). We headline the uncorrected statistic, 10.8 with p = 0.00102, per Fagerland et al.; the corrected value appears only so a reader reconciling against R’s default output knows why their number differs. With 30 discordant pairs, every switch rule in circulation (including the customary below-25 exact-switch rule) agrees the asymptotic form is legitimate here.
The test rejects marginal homogeneity: reviewer B genuinely approves at a higher rate than reviewer A on the same queue. It does not say the reviewers disagree often (they agree on 85% of cases), and it does not measure agreement (that is kappa’s job; SAS’s own documentation states the null as equality of the discordant probabilities). High agreement and a decisive McNemar coexist without contradiction because they are computed from different cells of the same table.
The actionable reading mirrors the ICC lesson’s calibration experiment: this is a calibration finding, not a competence finding. The reviewers rank cases similarly; one of them holds a looser bar. The remedy is aligning the bar, not retraining a reviewer.
The tempting error is the ordinary chi-square test of independence on the same 2x2 table. It is illegal here because the two verdicts on a case are not independent samples: they are the same case, twice. Pembury Smith & Ruxton (2020) document published examples of exactly this misuse, and their survey found papers rarely even state which McNemar variant they used (none of their surveyed 50 used the recommended mid-p). The chooser rule:
sessionInfo()$R.version$version.string
## [1] "R version 4.5.1 (2025-06-13)"
Your turn
Bring your own data and the question you actually need answered.
CympleData Scientist Send me your data and question, I’ll send you the analytics. ds@mcpanalytics.ai