McNemar's Test Calculator

Perform McNemar's test for paired binary data. Compute chi-square statistic, exact binomial p-value, odds ratio, and compare correction methods on matched pairs.

McNemar\'s Test Calculator

Paired 2ร—2 Table

Rows = Condition 1 (Before), Columns = Condition 2 (After)
After +After โˆ’
Before +
Before โˆ’
ฯ‡ยฒ Statistic
4.0500
McNemar's chi-square with Yates' correction, 1 df
p-Value (Asymptotic)
0.0442
Significant at ฮฑ = 0.05
p-Value (Exact Binomial)
0.0414
Exact two-sided test based on discordant pairs
Decision
Reject Hโ‚€
Marginal proportions differ significantly
Discordant Pairs
b = 5, c = 15 (total = 20)
Only discordant pairs (b and c cells) inform the test
Odds Ratio (b/c)
0.3333
Ratio of discordant pair counts

Marginal Proportions

MeasureValue
Proportion positive โ€” Before (a+b)/n0.2500 (25.0%)
Proportion positive โ€” After (a+c)/n0.3500 (35.0%)
Difference (pโ‚ โˆ’ pโ‚‚)-0.1000 (-10.0%)
Concordant +/+ pairs (a)20
Concordant โˆ’/โˆ’ pairs (d)60
Discordant +/โˆ’ pairs (b)5
Discordant โˆ’/+ pairs (c)15
Total observations100

Comparison of Corrections

Methodฯ‡ยฒp-value
No Correction5.00000.0253
Yates\' Correction4.05000.0442
Edwards\' Correction4.51250.0336
Exact Binomialโ€”0.0414

Visual: Discordant Pairs

b = 5
+/โˆ’
c = 15
โˆ’/+
Planning notes, formulas, and examples

About the McNemar's Test Calculator

McNemar's test is designed for paired binary data โ€” situations where the same subjects are measured under two conditions (before/after, test A/test B) with a yes/no outcome. Unlike the chi-square test of independence, which assumes independent observations, McNemar's test properly accounts for the paired structure of the data.

This calculator takes a paired 2ร—2 contingency table and computes the McNemar statistic with optional continuity corrections (Yates' or Edwards'), the exact binomial p-value, and marginal proportion differences. It also compares results across all correction methods in a single summary table.

Common applications include evaluating treatment effects in before-after studies, comparing diagnostic test accuracy, assessing attitude changes in matched surveys, and testing agreement patterns in reliability studies.

When This Page Helps

When your data consists of matched pairs with binary outcomes, an ordinary chi-square test is inappropriate because it ignores the pairing structure. McNemar's test focuses only on the discordant pairs โ€” the cases where the two conditions disagree โ€” providing a valid test of whether the marginal proportions differ. This calculator handles all the math and lets you compare correction methods side by side.

How to Use the Inputs

  1. Enter the four cells of the paired 2ร—2 table: a (both +), b (before +, after โˆ’), c (before โˆ’, after +), d (both โˆ’).
  2. Or click a preset example for common scenarios.
  3. Select a continuity correction method (Yates', Edwards', or none).
  4. Set your significance level alpha.
  5. Review the chi-square statistic and p-values (asymptotic and exact).
  6. Examine marginal proportions to see the direction of change.
  7. Compare all correction methods in the summary table.
Formula used
McNemar's Test (no correction): ฯ‡ยฒ = (b โˆ’ c)ยฒ / (b + c) With Yates' correction: ฯ‡ยฒ = (|b โˆ’ c| โˆ’ 1)ยฒ / (b + c) Exact Binomial Test: Under Hโ‚€, b ~ Binomial(b + c, 0.5) p-value = 2 ร— P(X โ‰ค min(b, c)) Where: a = concordant +/+ pairs b = discordant +/โˆ’ pairs c = discordant โˆ’/+ pairs d = concordant โˆ’/โˆ’ pairs

Example Calculation

Result: ฯ‡ยฒ = 4.05 (Yates'), p = 0.0442

With 5 discordant +/โˆ’ pairs and 15 discordant โˆ’/+ pairs, McNemar's test with Yates' correction gives ฯ‡ยฒ = 4.05 (1 df), p = 0.044. This is significant at ฮฑ = 0.05, indicating the marginal proportions differ โ€” more subjects changed from negative to positive than the reverse.

Tips & Best Practices

  • Only the discordant pairs (b and c cells) contribute to the test. Concordant pairs (a and d) are irrelevant for testing marginal differences.
  • Use the exact binomial test when the total number of discordant pairs (b + c) is small (under 25).
  • Yates' continuity correction makes the test more conservative, reducing the chance of a Type I error at the cost of power.
  • The odds ratio b/c quantifies the direction and magnitude of the discordance.
  • McNemar's test is a special case of Cochran's Q test for two related groups (k = 2).
  • Check that your data is truly paired โ€” the same subjects measured twice. If subjects differ between conditions, use chi-square instead.

Understanding the Paired 2ร—2 Table

In McNemar's setup, each subject contributes to exactly one cell. Cell a contains subjects who were positive on both occasions, d those negative on both, b those who changed from positive to negative, and c those who changed from negative to positive. The test asks whether b and c differ more than expected by chance alone.

Choosing a Correction Method

The uncorrected McNemar statistic can give slightly liberal p-values with small discordant counts. Yates' correction subtracts 1 from |b โˆ’ c| to better approximate the discrete binomial distribution with a continuous chi-square. Edwards' correction subtracts 0.5 instead. For very small discordant counts (under 10), the exact binomial test is recommended regardless.

Applications in Medical Research

McNemar's test is ubiquitous in diagnostic accuracy studies. When comparing two diagnostic tests applied to the same patients, it determines whether the tests have different sensitivity or specificity. In clinical trials with crossover designs, it tests treatment effects on binary endpoints. In epidemiology, it's used for matched case-control studies.

Sources & Methodology

Last updated:

Frequently Asked Questions

  • It tests whether the marginal row and column proportions in a paired 2ร—2 table are equal. Common uses: before/after studies, comparing two diagnostic tests on the same patients, and assessing attitude changes in panel surveys.