On this page
When a McNemar test fits paired yes-or-no outcomes
A McNemar test evaluates whether the marginal probability of a binary outcome changes between two conditions measured on the same independent pairs. A pair might be one person assessed before and after an intervention, or one matched unit measured under two conditions. Each pair contributes one result to each condition, and each result has exactly two categories.
The row and column totals alone do not determine this test. McNemar’s calculation uses the two discordant cells: pairs that changed from no to yes and pairs that changed from yes to no. Pairs that stayed no or stayed yes are concordant and do not contribute to the test statistic. Keep the table order shown in the calculator.
Worked example with matched before-and-after counts
This constructed example illustrates the calculation; it is not an observed study. Suppose 20 pairs are no at both times, 12 change from no to yes, 3 change from yes to no, and 15 are yes at both times. The discordant total is 12 + 3 = 15. Among those 15 changes, the exact null model assigns equal probability to either direction.
The observed positive proportion is 18/50 = 36% before and 27/50 = 54% after, a descriptive increase of 18 percentage points. Under a two-sided exact binomial test, the p-value is 0.035156. This p-value tests equality of the two marginal probabilities under the paired design; it does not measure practical importance, prove an effect or replace an interval estimate.
Exact binomial and chi-square methods answer the same null differently
Condition on the number of discordant pairs, m = b + c. Under the null hypothesis that the two directions are equally probable, the number of no-to-yes transitions follows a Binomial(m, 0.5) distribution. The exact method uses this distribution and can calculate a two-sided or prespecified directional alternative. The two-sided convention used here doubles the smaller binomial tail and caps the result at one.
For larger discordant totals, a chi-square approximation with one degree of freedom is also common. Its statistic is (b − c)²/(b + c); the continuity-corrected version uses max(|b − c| − 1, 0)²/(b + c). The page labels the selected method and correction because they can give different p-values, especially when discordant counts are limited. The exact implementation is bounded at 10,000 discordant pairs; for a larger table, select the approximation and review its conditions.
Study-design checks and limits
The pairs themselves should be mutually independent. Each pair must have one binary result under each condition, and the categories must have the same meaning before and after. Repeated measurements clustered within people, classrooms or sites are not independent pairs; this 2 × 2 tool does not model that structure.
Do not use McNemar’s test for two separate independent groups. For independent binary groups, use a method that matches the counts and design, such as a two-proportion test or, for a sparse independent 2 × 2 table, Fisher’s exact test. For matched numerical measurements, compare paired differences with a method suited to the outcome, such as a paired t-test. A study-design selector can help distinguish these questions.
Free paired binary-outcome calculator
Calculate McNemar’s test
Enter counts for the same independent pairs under two conditions. Rows show before; columns show after. The example is constructed for demonstration.
Only the two discordant cells determine the test. The exact option uses a binomial model with p = 0.5; the correction applies only to the chi-square approximation.
The calculation runs in this browser. Only aggregate counts are needed; do not enter identifiers or confidential information.
The constructed example is ready. Calculate to view its result.
McNemar test result
Selected-method p-value:
- Number of pairs
- Discordant pairs (no → yes / yes → no)
- Positive proportion before / after
- Observed difference (after − before)
- Test statistic
- Method
Questions about this topic
What does the McNemar test compare?
It tests whether the two marginal probabilities are equal for a binary outcome recorded twice on each independent pair. The test conditions on discordant pairs and compares the two directions of change.
Which cells go into the McNemar test?
Only the discordant cells: before no/after yes and before yes/after no. Concordant pairs remain important for describing the data but do not enter the test statistic.
Should I choose exact or chi-square?
The exact conditional binomial method is available for up to 10,000 discordant pairs and supports two-sided or directional alternatives. The large-sample chi-square method is two-sided here and can include a continuity correction. Choose in line with your analysis plan and report the method.
Can I use McNemar’s test for two independent groups?
No. It requires paired binary outcomes. For separate independent groups, choose a two-proportion or other method that matches the study design.
Are my counts uploaded?
No. This calculator runs in your browser and uses only the four aggregate table counts. Do not enter names or other identifying information.
Sources and editorial notes
The supporting reading below informs our editorial guidance. Exercises and scenarios illustrate a method; they do not report a completed product test or measured learning outcome. Read our editorial policy or send a correction with a supporting source to info@ai-essay.com.