McNemar's Test Calculator

Test for significant differences in paired binary outcomes - before/after studies and matched pairs.

M McNemar's Test Calculator

Enter paired 2×2 table: rows = first measurement, columns = second measurement.

Time 2: YesTime 2: No
Time 1: Yes
Time 1: No

Discordant Pairs

b (Yes→No)
-
c (No→Yes)
-
Total discordant (b+c)
-

Test Statistics

McNemar χ²
-
χ² (continuity corrected)
-
p-value (uncorrected)
-
p-value (corrected)
-
Odds ratio (b/c)
-

📖 What is McNemar's Test?

McNemar's test is a non-parametric statistical test designed for paired binary data. It tests whether the marginal proportions of a binary outcome are the same across two paired conditions - before and after a treatment, two diagnostic tests applied to the same patients, or two raters judging the same subjects. The test was introduced by Quinn McNemar in 1947 and is the standard method for paired categorical data in medical, psychological, and clinical research.

The key insight of McNemar's test is that only the discordant pairs carry information about change. Concordant pairs (both Yes or both No) tell us nothing about whether the conditions differ - they show no change. The discordant pairs in cell b (Yes in condition 1, No in condition 2) and cell c (No in condition 1, Yes in condition 2) are where all the evidence lies. If b = c, the marginal proportions are equal and there is no evidence of a systematic change. If b ≠ c substantially, the proportions differ significantly.

The test statistic is χ² = (b − c)²/(b + c), which follows a chi-square distribution with 1 degree of freedom under the null hypothesis of marginal homogeneity. For small discordant counts (b + c < 25), the Edwards continuity-corrected version χ²_cc = (|b − c| − 1)²/(b + c) is preferred. The odds ratio b/c gives the direction and magnitude of change: values above 1 indicate more subjects changed from Yes to No than from No to Yes.

McNemar's test is used extensively in clinical trials to compare before-and-after treatment responses, in diagnostic accuracy studies to compare two tests on the same patient, in ophthalmology to compare outcomes in paired eyes, and in education to compare pre-test and post-test pass rates on the same students.

📐 Formulas

McNemar χ² = (b − c)² / (b + c)

Continuity-corrected version (Edwards, 1948): χ²_cc = (|b − c| − 1)² / (b + c)

p-value: P(χ²₁ ≥ χ²_observed) - upper tail of chi-square distribution with df = 1.

Odds ratio of discordant pairs: OR = b / c

Table notation:

a = condition 1 positive & condition 2 positive (concordant Yes)

b = condition 1 positive & condition 2 negative (discordant: Yes → No)

c = condition 1 negative & condition 2 positive (discordant: No → Yes)

d = condition 1 negative & condition 2 negative (concordant No)

Null hypothesis: b = c (marginal homogeneity - the probability of the outcome is the same in both conditions).

📖 How to Use This Calculator

1
Arrange your data as a paired 2×2 table. Each subject has two measurements. Rows = first measurement (before/test 1), columns = second measurement (after/test 2).
2
Count: a = both positive (no change, Yes→Yes); b = changed from positive to negative (Yes→No); c = changed from negative to positive (No→Yes); d = both negative (No→No).
3
Click Calculate. If b + c < 25, use the continuity-corrected p-value. If significant, the intervention caused a statistically significant change in the binary outcome rate.

💡 Example Calculations

Example 1 - Before/after treatment response (significant)

1
Setup: 100 patients assessed for a symptom before and after treatment. a = 40 (symptom both times), b = 6 (symptom before, not after), c = 19 (no symptom before, symptom after), d = 35 (no symptom both times).
2
Discordant pairs: b = 6, c = 19, b + c = 25. McNemar χ² = (6 − 19)² / 25 = 169/25 = 6.76.
3
p-value = 0.009 - the symptom rate changed significantly. More patients developed the symptom (c = 19) than lost it (b = 6) after treatment, suggesting the treatment may be causing the symptom.
4
OR = b/c = 6/19 = 0.32 - the odds of having the symptom are lower post-treatment than pre-treatment among discordant pairs, meaning fewer patients were positive at time 2 relative to discordant cases.
McNemar χ² = 6.76, p = 0.009 (significant), OR = 0.32
Try this example →

Example 2 - Two diagnostic tests on the same patients

1
Setup: 200 patients tested for a condition with Test A and Test B. a = 90 (both positive), b = 20 (Test A+, Test B−), c = 15 (Test A−, Test B+), d = 75 (both negative). Do the tests have different positive rates?
2
χ² = (20 − 15)² / (20 + 15) = 25/35 = 0.71. Corrected: (|20−15|−1)²/35 = 16/35 = 0.46.
3
p = 0.40 (uncorrected), 0.50 (corrected) - not significant. The two tests have similar positive rates in this population. They disagree on 35 of 200 patients but not in a systematic direction.
McNemar χ² = 0.71, p = 0.40 (not significant), OR = 1.33
Try this example →

❓ Frequently Asked Questions

When should I use McNemar's test?+
Use McNemar's test when: (1) you have paired or matched binary data - each subject has two measurements (before/after, two conditions, two raters); (2) your outcome is binary (yes/no, positive/negative, pass/fail); (3) you want to test whether the probability of the outcome changed between conditions. Examples: testing whether a treatment changes the proportion of patients with a symptom, whether two diagnostic tests agree, whether a training programme changes pass rates among the same students. Do not use McNemar's for independent groups - use chi-square or Fisher's exact instead.
What are discordant pairs and why do only they matter?+
Discordant pairs are the pairs where the two measurements differ: cell b (Yes in condition 1, No in condition 2) and cell c (No in condition 1, Yes in condition 2). Concordant pairs (cell a = Yes/Yes, cell d = No/No) show no change and provide no information about whether the proportions are different. If b = c, the marginal proportions are equal and there is no evidence of change - the null hypothesis of marginal homogeneity holds. McNemar's test is essentially a binomial test (or chi-square test) on the proportion of discordant pairs that fall in one direction.
What is the difference between McNemar's test and chi-square test?+
The chi-square test of independence is used for independent groups - you compare two separate samples. McNemar's test is used for paired or matched data - you compare two measurements on the same subjects. Using chi-square on paired data ignores the pairing and loses statistical power; using McNemar's on independent data is incorrect and gives misleading results. McNemar's takes advantage of the within-subject correlation to achieve greater statistical power than a chi-square on the same data - similar to how a paired t-test is more powerful than an independent t-test.
What does the continuity correction do in McNemar's test?+
The McNemar chi-square statistic follows an asymptotic chi-square distribution with 1 df. For small discordant counts (b + c < 25), the discrete binomial distribution poorly approximates the continuous chi-square, leading to p-values that are slightly too small (anti-conservative). The Edwards continuity correction (|b − c| − 1)²/(b + c) adjusts for this by bringing the test statistic closer to the exact mid-p value. For b + c ≥ 25, the uncorrected version is fine. Some statisticians prefer the exact binomial test (mid-p McNemar) for small samples.
What does the odds ratio mean in McNemar's test?+
The odds ratio in McNemar's test is the ratio of the two types of discordant pairs: OR = b/c. It measures whether subjects are more likely to change in one direction than the other. OR = b/c > 1 means more subjects changed from Yes to No (b > c). OR = 1 means symmetric change. This is the conditional OR given that the pair is discordant. It is also the estimate of the marginal odds ratio and is equivalent to the odds ratio from a matched case-control design.
Can McNemar's test be used for more than 2 categories?+
McNemar's test is strictly for 2×2 tables with binary outcomes. For ordinal or polytomous outcomes with paired data, the appropriate extension is the Stuart-Maxwell test (for square k×k tables with k > 2 categories), Bowker's test of symmetry, or the marginal homogeneity test. These test whether the marginal distributions of the two measurements are equal across all categories, not just binary.
What is marginal homogeneity in the context of McNemar's test?+
Marginal homogeneity means that the row marginals equal the corresponding column marginals in the paired contingency table. For a 2×2 McNemar table: marginal homogeneity holds when P(Yes in condition 1) = P(Yes in condition 2), which means the prevalence of the outcome is the same in both conditions. McNemar's test is a test of marginal homogeneity. When the test is significant, the marginal proportions differ significantly between the two conditions - the intervention or time point changed the rate of the binary outcome.
What sample size do I need for McNemar's test?+
The critical factor is the number of discordant pairs (b + c), not the total n. With only 10 discordant pairs, McNemar's test has very low power. As a rule of thumb, you need at least 20–25 discordant pairs for reliable inference. For a priori power analysis: the power depends on the proportion of discordant pairs (b+c)/n and the hypothesised imbalance between b and c. Online tools (G*Power) compute McNemar's required sample size; you need to specify the expected proportion discordant and the proportion of discordant pairs in the b direction.