Experimentation & statistics
Using McNemar and other paired tests appropriately for within-subject binary outcome experiments.
This evergreen guide explains how to select and apply McNemar's test alongside related paired methods for binary outcomes in within-subject studies, clarifying assumptions, interpretation, and practical workflow, with concrete examples.
X Linkedin Facebook Reddit Email Bluesky
Published by Gregory Ward
August 12, 2025 - 3 min Read
When researchers compare two conditions on the same subjects, the data form a paired binary outcome structure. McNemar's test is a classic nonparametric tool designed specifically for such data, assessing whether there is a systematic shift in responses from one condition to another. Unlike tests that treat observations as independent, McNemar focuses on discordant pairs—instances where a subject switches from positive to negative or vice versa. The test uses a simple difference in the counts of these cross-over cases, producing a chi-squared statistic under the null hypothesis of no treatment effect. Its strength lies in requiring minimal distributional assumptions while delivering interpretable results.
Before applying McNemar, verify that your study design truly reflects paired observations. Each subject must be measured in both conditions, with a clearly defined binary outcome. For example, a diagnostic test where a patient is classified as positive or negative under two screening methods, or a usability study where participants either succeed or fail within each design variant. Ensure data quality by checking entry accuracy and confirming that missingness is random or addressed through sensitivity analyses. When the data meet these criteria, McNemar’s test provides a principled way to detect whether the proportion of discordant outcomes differs significantly from what would be expected by chance alone.
Complementary tests address varied questions about paired data.
The core calculation of McNemar’s test hinges on the off-diagonal counts in a 2x2 contingency table. Specifically, n01 and n10 represent cases where the subject’s outcome flips between conditions. The formula uses the squared difference (n01 − n10)² divided by the sum (n01 + n10), which follows a chi-squared distribution with one degree of freedom under large samples. For small samples, an exact McNemar test can be computed using a binomial distribution conditional on the total number of discordant pairs. In practice, many software packages automatically decide between the asymptotic and exact approaches based on sample size thresholds and user input.
ADVERTISEMENT
ADVERTISEMENT
Beyond the standard form, researchers often encounter extensions of McNemar for more nuanced questions. For instance, stratified McNemar adjusts for confounding variables by analyzing within-stratum discordance and then combining results. Another variant, the McNemar–Bowker test, generalizes the idea to multi-category outcomes, though it moves beyond binary results. When outcomes evolve over time, paired tests can be complemented by time-to-event analyses or transitional models. The key is to align the statistical method with the study’s hypotheses, the scale of measurement, and the availability of paired observations across conditions.
Planning analyses with robust handling of limitations and errors.
If your binary outcome is not simply pass/fail but involves multiple yes/no dimensions, you may still prefer within-subject analyses that preserve pairing structure. For example, a researcher evaluating two learning interventions per student might analyze each item separately and then combine the results with careful pooling methods. In such settings, Stuart–Maxwell tests or related marginal homogeneity assessments can capture broader patterns of change across categories, while still respecting the paired nature of the data. These approaches avoid pooling all information into a single dichotomy and instead provide a more granular view of where effects are strongest.
ADVERTISEMENT
ADVERTISEMENT
When planning an experiment, pre-specify the analytical plan to handle potential imbalances or missing data in paired outcomes. Consider conducting a sensitivity analysis to understand how different missingness mechanisms could influence the McNemar statistic. If a sizable portion of subjects lack measurements in one condition, you may need to use paired imputations or switch to an analysis that tolerates incomplete pairing. Transparent reporting should include the rationale for choosing exact versus asymptotic tests, how discordant counts were handled, and the implications for the study’s statistical power.
Transparent reporting and practical guidance for researchers.
The interpretation of McNemar’s result centers on the direction and significance of the discordant-pair imbalance. A significant outcome indicates that the two conditions yield different probabilities of the binary response in the paired population. Practically, this means that one condition tends to produce more positive outcomes than the other, beyond what chance would permit. In presenting results, report the raw discordant counts (n01 and n10), the test statistic, the exact or approximate p-value, and a straightforward statement about which condition performs better. Communicate any practical considerations, such as clinical relevance or usability implications.
It is essential to accompany any McNemar analysis with diagnostics that assess its assumptions. While the test itself is robust to many departures, large imbalances in marginal totals or extreme proportions can distort p-values, especially in small samples. Check the symmetry of the data and confirm that the paired design was properly implemented, with no crossover contamination or inconsistent measurement criteria. When reporting, include a short note on sample size considerations and how they influence the choice between an exact versus an asymptotic approach, so readers understand the reliability of the results.
ADVERTISEMENT
ADVERTISEMENT
Integrating paired tests into a rigorous experimental workflow.
Another perspective is to consider Bayesian alternatives for paired binary data, which can provide probabilistic interpretations and incorporate prior information. A Bayesian framework can yield posterior odds of improvement by conditioning on the observed discordance structure, offering intuitive measures like credible intervals for the difference in performance between conditions. While not as widely taught as McNemar in basic statistics courses, Bayesian methods can be valuable when prior knowledge exists or when we wish to update conclusions as data accumulate. Presenters should clearly state priors and sensitivity analyses to maintain credibility and reproducibility.
Additionally, researchers often face multiple testing concerns when evaluating several outcomes or multiple time points within the same study. In paired designs, adjustment methods such as Bonferroni or false discovery rate procedures help control error rates across hypotheses. When possible, embed hierarchical or composite testing strategies to maintain interpretability without inflating type I error. Predefining the set of primary and secondary endpoints prevents post hoc reasoning from undermining the credibility of the inside-subject comparisons. A thoughtful testing plan strengthens the overall integrity of the experiment.
In practice, a well-structured workflow begins with a clear hypothesis about the effect of condition on the binary outcome. Data collection should guarantee proper pairing, with consistent measurement rules applied across conditions. During analysis, start with McNemar to assess overall directional change, then explore extensions or complementary tests if the data demand more nuance. It is wise to document all decisions about handling missing data, choosing exact versus asymptotic tests, and any stratification used. A transparent narrative helps readers reproduce results and trust that the conclusions reflect genuine within-subject differences rather than artifacts.
Finally, cultivate an intuition for when paired tests are most informative. These methods excel when individual subjects serve as their own controls, reducing between-subject variability and sharpening the signal of a treatment or design effect. They are less suitable when independence assumptions hold for each observation or when outcomes are highly rare in both conditions. By pairing solid design with appropriate statistical tests and clear reporting, analysts can produce robust, actionable insights from within-subject binary experiments that endure beyond a single study.
Related Articles
Experimentation & statistics
Designing effective experiments to quantify the added impact of specific ranking tweaks across diverse user segments, balancing rigor, scalability, and actionable insights for sustained performance.
July 26, 2025
Experimentation & statistics
This evergreen guide explains how stratification and related variance reduction methods reduce noise, sharpen signal, and accelerate decision-making in experiments, with practical steps for robust, scalable analytics.
August 02, 2025
Experimentation & statistics
In modern experiment-driven modeling, calibration and reliability diagrams provide essential perspectives on how well probabilistic outputs reflect real-world frequencies, guiding model refinement, deployment readiness, and trust-building with stakeholders through clear, visual diagnostics and disciplined statistical reasoning.
July 26, 2025
Experimentation & statistics
Targeted randomization blends statistical rigor with practical product insight, enabling teams to discover nuanced user segment behaviors quickly, while minimizing wasted effort, data waste, and deployment risk across evolving markets.
July 24, 2025
Experimentation & statistics
Cost-aware experimentation blends analytics with strategic budgeting, ensuring scarce resources maximize value, accelerate learning, and guide decision-making by weighing impact against expense, risk, and time horizons.
July 29, 2025
Experimentation & statistics
This article explores robust strategies for tracking how treatment effects endure or fade across long-running user cohorts, offering practical design patterns, statistical considerations, and actionable guidance for credible, durable insights.
August 08, 2025
Experimentation & statistics
A practical guide to structuring experiments that reveal how search ranking updates affect user outcomes, ensuring intent, context, and measurement tools align to yield reliable, actionable insights.
July 19, 2025
Experimentation & statistics
As teams chase rapid insights, they must balance immediate online experiment speed with the deeper, device-agnostic reliability that offline simulations offer, ensuring results are actionable and trustworthy.
July 19, 2025
Experimentation & statistics
In early-stage testing, factorial designs offer a practical path to identify influential factors efficiently, balancing resource limits, actionable insights, and robust statistical reasoning across multiple variables and interactions.
July 26, 2025
Experimentation & statistics
In large-scale experimentation, minor signals emerge sporadically; hierarchical modeling offers a principled method to borrow strength across diverse trials, stabilizing estimates, guiding decisions, and accelerating learning when rare events provide limited information from any single study.
July 19, 2025
Experimentation & statistics
As researchers, we must routinely verify covariate balance after random assignment, recognize signals of imbalance, and implement analytic adjustments that preserve validity while maintaining interpretability across diverse study settings.
July 18, 2025
Experimentation & statistics
Propensity-weighted estimators offer a robust, data-driven approach to adjust for unequal dropout or censoring across experimental groups, preserving validity while minimizing bias and enhancing interpretability.
July 17, 2025