McNemar Test Calculator

McNemar Test Calculator

Compare paired proportions — the same people measured twice, before and after a treatment, or two raters judging the same cases. Enter the paired 2×2 table and get the chi-square statistic, the exact binomial p-value and the odds ratio.

After: YesAfter: No
Before: Yes
Before: No

a = yes both times, b = yes then no, c = no then yes, d = no both times. The yellow cells are the discordant pairs — the only people who changed.

Exact binomial p-value
0.0768

Fail to reject H₀ at α = 0.05 — no significant change.

χ² (no correction)
4.000
p-value (χ²)
0.0455
χ² (Yates correction)
3.0625
p-value (Yates)
0.0801
Odds ratio (b / c)
3.00
OR 95% CI
[0.97, 9.30]

How it was worked out

    Paired 2×2 table and chart

    The yellow cells are the discordant pairs. McNemar’s test compares b and c only — a and d (the people who did not change) do not affect the test statistic.

    McNemar’s test compares paired proportions — the same people measured twice, before and after a treatment, or two raters judging the same cases. It looks only at the people who changed: the discordant pairs. This calculator reports the chi-square statistic with and without continuity correction, the exact binomial p-value and the odds ratio.

    How to use the McNemar test calculator

    Count each pair into one of the four cells of the 2×2 table: a (yes both times), b (yes then no), c (no then yes) and d (no both times). Then:

    1. Enter the four counts into the table above — or press Load Example 1, Load Example 2 or Load Edge Case to see the worked examples.
    2. Choose the significance level (α); 0.05 is the usual choice.
    3. Read the headline exact binomial p-value, then check the results grid for the chi-square statistic with and without Yates’ continuity correction, the odds ratio and its 95% confidence interval.
    4. Read the “How it was worked out” ledger to see every step, and the chart and table below it for the counts in each cell.

    Try it now: with a = 30, b = 12, c = 4 and d = 54, the calculator gives χ² = 4.000, p = 0.0455, a Yates-corrected χ² of 3.0625 (p = 0.0801) and an exact binomial p-value of 0.0768 — not significant at the 5% level, because there are only 16 discordant pairs.

    When should you use McNemar’s test?

    Use McNemar’s test when you have paired binary data — two measurements of the same yes/no outcome on the same people or the same cases. Typical uses:

    • Before and after: did a treatment change the outcome for the same patients?
    • Two raters or two methods: do two diagnostic tests agree on the same patients, or do two judges rate the same cases differently?
    • Matched pairs: case–control pairs in which each case is matched to a control on the same characteristic.

    It is the paired version of the chi-square test: the chi-square test of independence is for two different groups, while McNemar’s test is for the same people measured twice. If the data are paired but continuous, use the Wilcoxon signed-rank test; if they are paired counts of “which is higher”, the sign test is the closest relative. For agreement between two raters, Cohen’s kappa measures how far agreement exceeds chance; McNemar’s test asks the different question of whether one rater says yes systematically more often than the other. The odds ratio itself is explained in the odds ratio calculator, and the confidence interval for a proportion calculator covers a single proportion.

    Rule of thumb: if b + c < 25, report the exact binomial p-value, not the chi-square p-value. The chi-square approximation needs enough discordant pairs to be trustworthy, and with fewer than 25 it can call a result significant when it is not.

    How McNemar’s test works

    The test looks only at the discordant pairs, b and c — the people who changed. The concordant pairs, a and d, tell you nothing about change: everyone in those cells gave the same answer both times, so they cannot move the test either way. That is why the test statistic uses b and c alone.

    Chi-square statistic. Under the null hypothesis of no change, b and c should be equal — half the changers in each direction. The statistic is χ² = (b − c)² / (b + c), with 1 degree of freedom. The p-value comes from the chi-square distribution with df = 1.

    Yates’ continuity correction. Because the chi-square distribution is continuous and the counts are discrete, Yates’ correction subtracts 1 from |b − c| before squaring: χ² = (|b − c| − 1)² / (b + c). It pulls the statistic towards zero and is more conservative; when b = c the corrected statistic is 0 and the p-value is 1.0.

    Exact binomial p-value. With n = b + c discordant pairs, the number changing in one direction follows a binomial distribution with p = 0.5 under the null. Taking k = min(b, c), the two-sided exact p-value is p = 2 × P(X ≤ k), where X ~ Bin(n, 0.5). It needs no approximation, so it is the p-value to report whenever b + c < 25.

    Odds ratio. The odds ratio for paired data is OR = b / c: how many times more people changed in one direction than the other. Its 95% confidence interval is built on the log scale, exp(ln(OR) ± 1.96 · √(1/b + 1/c)). If the interval includes 1, the data are compatible with equal change in both directions.

    Worked examples

    Example 1 — before and after treatment (N = 100)

    One hundred patients are assessed before and after a treatment. Thirty improved and stayed improved (a = 30), 12 improved then relapsed (b = 12), 4 did not improve then improved (c = 4) and 54 never improved (d = 54).

    After: YesAfter: NoRow total
    Before: Yes301242
    Before: No45458
    Column total3466100

    There are b + c = 16 discordant pairs, fewer than 25, so the exact p-value is the one to report. The uncorrected test gives χ² = (12 − 4)² / 16 = 4.000, p = 0.0455; with Yates’ correction, χ² = 3.0625, p = 0.0801; and the exact binomial p-value is 0.0768. The odds ratio is OR = 12 / 4 = 3.00, 95% CI [0.97, 9.30].

    The uncorrected test is significant at 5%, but the exact test is not (p = 0.0768) — with only 16 discordant pairs, the honest answer is “not significant”. The odds ratio of 3.00 means three times as many people changed yes-to-no as no-to-yes, but its confidence interval includes 1, so the data are still compatible with no change.

    Example 2 — two diagnostic methods (N = 30)

    Thirty patients are tested by two diagnostic methods. Both methods agree positive for 5 patients (a = 5) and negative for 15 (d = 15); method 1 is positive and method 2 negative for 8 patients (b = 8), and the reverse for 2 (c = 2).

    After: YesAfter: NoRow total
    Before: Yes5813
    Before: No21517
    Column total72330

    With b + c = 10 discordant pairs, the exact p-value is again the one to report. The uncorrected test gives χ² = (8 − 2)² / 10 = 3.600, p = 0.0578; with Yates’ correction, χ² = 2.500, p = 0.1138; and the exact binomial p-value is 0.1094. The odds ratio is OR = 8 / 2 = 4.00, 95% CI [0.85, 18.84].

    There is no significant difference between the methods. The odds ratio of 4.00 looks large, but the wide confidence interval (0.85 to 18.84) shows how little 10 discordant pairs can say — the data are compatible with anything from a small advantage for method 2 to a very large advantage for method 1.

    Edge case — a zero cell (b = 1, c = 0)

    Suppose a = 10, b = 1, c = 0 and d = 10. Only one person changed, and in one direction only. The chi-square statistic is χ² = 1.000, p = 0.3173, and the corrected statistic is 0 (p = 1.0). The exact binomial p-value is 1.0 — with a single discordant pair, either direction is equally likely under the null.

    The raw odds ratio is b / c = 1 / 0, which is infinite. The calculator reports it as ∞ and gives the Haldane–Anscombe interval instead: adding 0.5 to each cell gives OR = 3.00 with a 95% CI of [0.12, 73.65]. The interval is enormous, which is the honest statement: one changed pair says almost nothing about the odds ratio.

    How to interpret the results

    • Exact binomial p-value (headline): the p-value to report whenever b + c < 25. If it is below α, the proportions before and after differ; if it is above, they do not differ significantly.
    • Chi-square p-value: the approximation. It is fine when b + c ≥ 25, but with fewer discordant pairs it can be too small — as in Example 1, where it says 0.0455 while the exact p-value is 0.0768.
    • Yates-corrected p-value: more conservative than the uncorrected test. It is a useful cross-check, but the exact p-value is preferred when b + c < 25.
    • Odds ratio: above 1 means more people changed yes-to-no than no-to-yes; below 1 means the reverse. The 95% CI tells you how precisely the ratio is known — a wide interval means few discordant pairs.
    • Discordant pairs (b + c): the effective sample size of the test. A large total N means little if almost nobody changed.

    Assumptions

    • Each pair contributes one observation to the table, and the pairs are independent of each other.
    • The outcome is dichotomous (yes/no, present/absent) at both measurements.
    • The same subjects or cases are measured twice (or the pairs are matched). If the two groups are independent samples, use the chi-square test of independence instead.
    • For the chi-square approximation, b + c should be at least 25; otherwise use the exact binomial p-value, which needs no such assumption.
    • For the odds ratio confidence interval, b and c should both be non-zero; the calculator applies the Haldane–Anscombe +0.5 correction when one of them is zero.

    Reporting your result (APA)

    Report the corrected chi-square statistic with its degrees of freedom and p-value, and give the exact binomial p-value and the odds ratio with its 95% confidence interval whenever b + c < 25. Copy and adapt this sentence for Example 1:

    McNemar’s test showed no significant change in outcome after treatment, χ²(1) = 3.06, p =.080 (exact binomial p =.077, OR = 3.00, 95% CI [0.97, 9.30]).

    For Example 2, the equivalent sentence is:

    The two diagnostic methods did not differ significantly, χ²(1) = 2.50, p =.114 (exact binomial p =.109, OR = 4.00, 95% CI [0.85, 18.84]).

    Note that the chi-square value quoted is the Yates-corrected one, because that is the conservative figure to pair with the exact p-value when the discordant count is small.

    Cite this tool

    Shafiq, A. (2026). McNemar Test Calculator. Empirical Rule Calculators. https://empiricalrulecalculators.com/mcnemar-test-calculator/

    Frequently asked questions

    What is the difference between McNemar’s test and the chi-square test of independence?

    The chi-square test of independence is for two different groups — for example, men and women — and asks whether the outcome differs between them. McNemar’s test is for the same people measured twice, and asks whether the outcome changed. The two tests use different tables: independence uses row and column totals from independent samples, while McNemar’s test uses only the discordant pairs, b and c. Using the independence test on paired data is a common mistake — it treats the two measurements as if they came from different people.

    When do I use the exact p-value?

    Use the exact binomial p-value whenever b + c < 25 — that is, whenever there are fewer than 25 discordant pairs. The chi-square p-value is an approximation that needs enough changers to be accurate; with few changers it can be too small and declare a result significant when it is not. When b + c ≥ 25, the chi-square and exact p-values are close, and either is fine. This calculator always shows the exact p-value as the headline, so you can simply report it.

    What are discordant pairs?

    Discordant pairs are the pairs that changed: b (yes then no) and c (no then yes). The concordant pairs, a (yes both times) and d (no both times), did not change, so they carry no information about whether the treatment or the second method made a difference — they drop out of the test entirely. The effective sample size of McNemar’s test is b + c, not the total N.

    What if b or c is zero?

    If c = 0, the odds ratio b / c is infinite; if b = 0, it is 0. The calculator reports the raw value (∞ or 0.00) and gives the Haldane–Anscombe interval instead, which adds 0.5 to each cell before computing the odds ratio and its confidence interval. The chi-square and exact p-values are unaffected: with b = 1 and c = 0, for example, the exact p-value is 1.0, because a single discordant pair is equally likely to fall in either direction.

    How do I interpret the odds ratio?

    The odds ratio is b / c: the number of people who changed in one direction divided by the number who changed in the other. An odds ratio of 3.00 means three times as many people changed yes-to-no as no-to-yes. A value of 1 means equal change in both directions — no effect. Always read it with its 95% confidence interval: if the interval includes 1, the data are compatible with no change, however large the point estimate looks. And remember that the odds ratio says nothing about the people who did not change.

    Sources: McNemar, Q. (1947). Note on the sampling error of the difference between correlated proportions or percentages. Psychometrika, 12(2), 153–157. Yates, F. (1934). Contingency tables involving small numbers and the χ² test. Journal of the Royal Statistical Society, 1(2), 217–235. Haldane, J. B. S. (1956). The estimation and significance of the logarithm of a ratio of frequencies. Annals of Human Genetics, 20(4), 309–311; Anscombe, F. J. (1956). On estimating binomial response relations. Biometrika, 43(3–4), 461–464. All worked examples on this page were verified against SciPy 1.11.4 (scipy.stats.binomtest and scipy.stats.chi2).

    See all 106 free statistics tools on Empirical Rule Calculators.

    Next steps

    Keep going with the paired and categorical tests that pair with McNemar’s test.

    🎲● LiveChi-Square

    Chi-Square Test Calculator

    Test independence or goodness of fit for two independent groups — the unpaired counterpart of McNemar’s test.

    Try Calculator →

    🔀● LivePaired Test

    Sign Test Calculator

    The paired test for “which is higher” counts — the closest relative of McNemar’s test for paired data.

    Try Calculator →

    📊● LiveNonparametric

    Wilcoxon Signed-Rank Test Calculator

    The paired test for continuous data — use it when your paired measurements are scores, not yes/no answers.

    Try Calculator →

    More Tools to Explore

    Keep going with the calculators that pair with McNemar’s test — paired tests, proportions and effect sizes.

    🎲● LiveChi-Square

    Chi-Square Test Calculator

    Test independence or goodness of fit for two independent groups — the unpaired counterpart of McNemar’s test.

    Try Calculator →
    🔀● LivePaired Test

    Sign Test Calculator

    The paired test for “which is higher” counts — the closest relative of McNemar’s test for paired data.

    Try Calculator →
    📊● LiveNonparametric

    Wilcoxon Signed-Rank Test Calculator

    The paired test for continuous data — use it when your paired measurements are scores, not yes/no answers.

    Try Calculator →
    📊● LiveEffect Size

    Odds Ratio Calculator

    Compute the odds ratio and relative risk with confidence intervals for any 2×2 table.

    Try Calculator →
    🔔● LiveConfidence Interval

    Confidence Interval for a Proportion Calculator

    Build a Wilson or normal-approximation interval for a single proportion.

    Try Calculator →
    📊● LiveANOVA

    Repeated Measures ANOVA Calculator

    Compare three or more repeated measurements on the same people, with sphericity corrections.

    Try Calculator →
    🧭

    Explore All Tools

    Browse all 106 free statistics tools — every calculator on this site in one place.

    Browse All Tools