McNemar's test is the definitive nonparametric method for evaluating whether a statistically significant shift has occurred in binary outcomes measured on the same subjects at two points in time or under two matched conditions. Originally formulated by Quinn McNemar in 1947, the test addresses a specific limitation of independent-sample methods: when observations are paired — such as pre-treatment versus post-treatment measurements on identical patients — standard Pearson's chi-square tests violate the independence assumption and produce unreliable results.

This calculator automates the full McNemar's workflow, computing the chi-square statistic (with or without continuity correction), the associated p-value, odds ratio, difference in proportions, and confidence intervals. It is the gold standard tool for matched case-control studies, paired A/B testing, and any research design where the same population is evaluated under two dichotomous conditions.

Required Project Parameters

To perform a McNemar's analysis, the following classification counts from a 2×2 contingency table are required:

  • Concordant Positive Pairs (a): The number of subjects classified as positive under both conditions (e.g., positive on both Pre-test and Post-test). Measured in paired observation units.
  • Discordant Pairs — Positive-to-Negative Shift (b): Subjects positive in the first condition but negative in the second. These represent the regressive shift direction. Measured in paired observation units.
  • Discordant Pairs — Negative-to-Positive Shift (c): Subjects negative in the first condition but positive in the second. These represent the progressive shift direction. Measured in paired observation units.
  • Concordant Negative Pairs (d): Subjects classified as negative under both conditions. Measured in paired observation units.
  • Significance Level (Alpha): The probability threshold for rejecting the null hypothesis of marginal homogeneity. Standard thresholds include 0.10 (90% confidence), 0.05 (95% confidence), 0.01 (99% confidence), and 0.001 (99.9% confidence).
  • Continuity Correction: A methodological selection between the uncorrected chi-square formula and the Edwards/Yates corrected formula, which adjusts the test statistic to compensate for the discrete-to-continuous distribution approximation.

The Algebra of Marginal Discordance: Core Formulas and Theory

The Discordance Principle — Why Concordant Pairs Vanish from the Statistic

The single most distinctive property of McNemar's test is its exclusive reliance on discordant pairs. Cells $b$ and $c$ — the observations that changed classification between conditions — are the only values that enter the chi-square numerator. The concordant cells $a$ and $d$ carry zero information about directional shift and are algebraically eliminated.

This can be understood intuitively: if the goal is to detect whether the marginal proportions have shifted, only the cases that moved contribute evidence. A subject who was positive at both time points provides no discriminating power.

However, a critical nuance often overlooked in textbooks is that concordant pairs still determine the total sample size $N = a + b + c + d$. This total is essential for computing the difference in proportions, standard error, and confidence intervals. Discarding concordant pairs entirely would collapse these derivative metrics.

Uncorrected McNemar's Chi-Square

The foundational test statistic follows a chi-square distribution with 1 degree of freedom under the null hypothesis that $p_b = p_c$ (i.e., the probability of shifting in each direction is equal):

$$\chi^2 = \frac{(b - c)^2}{b + c}$$

The numerator captures the squared magnitude of directional asymmetry between the two types of discordant pairs. The denominator normalizes by the total volume of discordance. When $b \approx c$, the statistic approaches zero, supporting marginal homogeneity.

Edwards/Yates Continuity Correction

The chi-square distribution is continuous, yet the observed cell counts $b$ and $c$ are discrete integers. This mismatch introduces a systematic liberal bias — the uncorrected test rejects the null hypothesis slightly too often, inflating Type I error rates.

The Edwards/Yates correction compensates by reducing the absolute discordance by 1 before squaring:

$$\chi^2_{\text{corrected}} = \frac{(\lvert b - c \rvert - 1)^2}{b + c}$$

If $\lvert b - c \rvert < 1$, the numerator is set to zero to prevent negative values. This correction makes the test more conservative, and leading statisticians — including Agresti and Fleiss — recommend its use particularly when the total number of discordant pairs $(b + c)$ is modest. It directly reduces false positive conclusions in small-sample paired designs.

Marginal Odds Ratio

The odds ratio (OR) quantifies the relative magnitude of shift in one direction versus the other:

$$OR = \frac{b}{c}$$

An $OR > 1$ indicates a net shift from positive to negative (regressive dominance), while $OR < 1$ indicates a net shift from negative to positive (progressive dominance). An $OR = 1$ implies symmetry. If $c = 0$, the ratio is undefined (infinite), indicating an exclusively unidirectional shift.

Difference in Proportions and Its Confidence Interval

The difference in marginal proportions (often denoted $\Delta p$) estimates the net population-level shift:

$$\Delta p = \frac{b - c}{N}$$

The standard error for this difference, derived under the Wald method, is:

$$SE = \frac{\sqrt{(b + c) - \frac{(b - c)^2}{N}}}{N}$$

The confidence interval is then constructed as:

$$\Delta p \pm z_{\alpha/2} \times SE$$

Where $z_{\alpha/2}$ is the critical value of the standard normal distribution corresponding to the chosen significance level.

p-Value Derivation

The p-value is obtained from the right tail of the chi-square distribution with 1 degree of freedom. Computationally, this relies on the regularized incomplete gamma function $Q(a, x)$:

$$p = 1 - P(\chi^2_1 \leq \chi^2_{\text{obs}}) = Q!\left(\frac{1}{2},; \frac{\chi^2_{\text{obs}}}{2}\right)$$

If $p < \alpha$, the null hypothesis of marginal homogeneity is rejected, confirming a statistically significant shift in proportions.

Critical Value Thresholds and Methodological Selection Criteria

Standard Normal Critical Values by Confidence Level

Significance Level ($\alpha$)Confidence LevelTwo-Tailed $z_{\alpha/2}$Chi-Square Critical Value ($df = 1$)
0.1090%1.6452.706
0.0595%1.9603.841
0.0199%2.5766.635
0.00199.9%3.29110.828

A computed chi-square statistic exceeding the critical value in the rightmost column leads to rejection of the null hypothesis at the corresponding confidence level.

Test Variant Selection by Discordant Sample Size

Total Discordant Pairs $(b + c)$Recommended MethodRationale
$< 10$Exact Binomial TestAsymptotic approximation is unreliable; exact computation is mandatory
$10 – 24$Exact Binomial Test (preferred) or McNemar's with Edwards/Yates CorrectionChi-square approximation borderline; correction partially compensates
$25 – 50$McNemar's with Edwards/Yates CorrectionCorrection meaningfully reduces Type I error inflation
$> 50$Uncorrected McNemar's or Corrected McNemar'sBoth variants converge; correction has negligible practical impact

The threshold of 25 discordant pairs is widely cited in clinical biostatistics literature as the minimum for reliable asymptotic performance of McNemar's chi-square approximation.

FeatureMcNemar's TestCochran's Q TestPaired t-TestPearson's Chi-Square
Outcome TypeBinary (2 conditions)Binary (3+ conditions)ContinuousBinary
PairingMatched pairs requiredMatched/repeated measuresMatched pairs requiredIndependent groups
DistributionChi-square ($df = 1$)Chi-square ($df = k-1$)t-distributionChi-square ($df$ varies)
Key AssumptionDiscordant pair symmetryEqual proportions across conditionsNormally distributed differencesIndependent observations

This table clarifies a fundamental distinction: McNemar's test is designed exclusively for dependent binary data. Applying Pearson's chi-square to matched-pair designs violates the independence assumption and produces biased p-values.

Interpreting Marginal Shifts in Clinical and Experimental Practice

Reading the Discordant Asymmetry

The practical interpretation of McNemar's test centers on comparing the two discordant cells. When $b$ substantially exceeds $c$, the dominant shift is from positive to negative — for example, patients who responded to treatment at baseline but lost response post-intervention. Conversely, when $c$ substantially exceeds $b$, there is a dominant conversion toward the positive classification.

The shift ratios (the proportion of total discordance attributable to each direction) provide an immediate clinical summary. A split of $b = 15$ and $c = 5$ among 20 discordant pairs translates to a 75%/25% directional asymmetry — a clear imbalance in the direction of regressive shift.

How Concordant Volume Shapes Precision

Although $a$ and $d$ do not influence the test statistic itself, their combined magnitude directly governs the width of the confidence interval. Two studies may produce identical chi-square values from the same discordant counts, yet the study with a larger total $N$ (driven by more concordant pairs) will yield a tighter confidence interval around the difference in proportions.

This phenomenon has practical implications for study design. Increasing total enrollment improves the precision of the estimated treatment effect even if the additional subjects fall into the concordant cells. The standard error formula explicitly depends on $N$ in the denominator, so larger samples always sharpen estimation regardless of where those observations land in the contingency table.

The Odds Ratio as a Clinical Effect Measure

The marginal odds ratio $OR = b / c$ provides a complementary perspective to the p-value. A statistically significant result with $OR = 1.2$ indicates a modest directional preference, whereas $OR = 5.0$ reveals a strong asymmetry — one shift direction is five times more frequent than the other.

In matched case-control studies, the odds ratio directly estimates the exposure odds ratio under the rare-disease assumption. In pre-post intervention designs, it quantifies the relative likelihood of deterioration versus improvement. Reporting both the p-value and the OR is considered best practice, as significance without meaningful effect size can mislead clinical decision-making.

Frequently Asked Questions

Why does McNemar's test ignore the concordant cells when computing the chi-square statistic?

The null hypothesis of McNemar's test is marginal homogeneity — the proposition that the probability of being classified positive is identical across both conditions. Concordant pairs (subjects positive at both times, or negative at both) are consistent with both the null and alternative hypotheses; they contribute no discriminating information about whether a shift has occurred.

Algebraically, when deriving the expected frequencies under $H_0$, the concordant cells cancel. Only the discordant cells $b$ and $c$ produce a testable contrast. This is analogous to how a paired t-test examines only the differences within pairs rather than the raw scores.

That said, concordant pairs are not irrelevant to the full analysis. They contribute to total $N$, which determines the standard error and confidence interval width around the difference in proportions. A thorough analysis reports both the test statistic (driven by discordance) and the confidence interval (shaped by total sample size).

When should the Edwards/Yates continuity correction be applied instead of the uncorrected formula?

The continuity correction compensates for approximating a discrete binomial process with a continuous chi-square distribution. Without it, the test tends to be slightly anti-conservative — rejecting the null hypothesis more often than the nominal $\alpha$ level warrants. This bias is most pronounced when the number of discordant pairs is small.

The consensus in biostatistics literature is to apply the correction when $(b + c) < 50$, and it is strongly recommended when $(b + c) < 25$. Below approximately 10 discordant pairs, even the corrected chi-square becomes unreliable, and the exact binomial test (testing whether $b$ follows a $\text{Binomial}(b + c,; 0.5)$ distribution) should be used instead. For large discordant samples above 50, the corrected and uncorrected statistics converge, making the choice largely immaterial.

How does McNemar's test differ from a standard Pearson's chi-square test for 2×2 tables?

The critical distinction is the dependency structure of the data. Pearson's chi-square test assumes that all observations are independently sampled — each subject contributes to exactly one cell, and the rows and columns represent separate groups. McNemar's test, by contrast, is designed for matched pairs where the same subject (or a matched unit) contributes to both row and column classifications simultaneously.

Applying Pearson's chi-square to paired data ignores the within-subject correlation. This typically deflates the test statistic and produces inflated p-values, reducing statistical power to detect genuine shifts. McNemar's test correctly isolates the discordant pairs — the only pairs carrying information about change — and evaluates their symmetry. This makes it the appropriate choice for all pre/post designs, crossover trials, and matched case-control studies involving binary endpoints.

Toward Reliable Inference in Paired Dichotomous Research

Manual computation of McNemar's test — particularly when incorporating the Edwards/Yates correction, deriving p-values from the regularized incomplete gamma function, and constructing Wald-type confidence intervals — is error-prone and time-intensive. Misidentifying cells in the contingency table, forgetting to apply the continuity correction for small discordant samples, or using an independent-sample test on paired data are among the most common analytical errors in published clinical literature.

Automated mathematical estimation eliminates these risks. By systematically applying the correct formula variant based on the selected correction method, computing precise tail probabilities, and simultaneously reporting the odds ratio, proportion difference, and confidence bounds, the calculator ensures internally consistent results across all output metrics. This enables researchers and analysts to focus on the substantive interpretation — the clinical or experimental meaning of the observed marginal shift — rather than the mechanical execution of the statistical procedure.