Mcnemars Test - Paired Binary Outcomes

Free McNemars test calculator for paired binary data: type the four cells of a paired 2x2 table and get the chi-square statistic with continuity correction, exact binomial p-value, odds ratio, and a clear significance flag at alpha 0.05.

Mcnemars Test

Pairs where both methods gave the same 'no' or control answer.

Pairs where both methods gave the same 'yes' or treatment answer.

Discordant pairs where method 1 was 'yes' and method 2 was 'no'.

Discordant pairs where method 1 was 'no' and method 2 was 'yes'.

Results

Discordant Pairs (b + c)
0pairs
Chi-Square (no correction) 0
Chi-Square (with correction) 0
p-value (chi-square, 1 df) 0
p-value (exact binomial) 0
Odds Ratio (b / c) 0
Odds Ratio 95% CI 0
Degrees of Freedom 0
Significant at alpha = 0.05 0

What Is McNemar's Test?

The McNemars test is a non-parametric test for paired nominal data, often laid out as a 2x2 table of before-after or method-A versus method-B outcomes on the same subjects. This calculator reads the four cells, isolates the discordant cells (b and c), and returns the chi-square with and without continuity correction, the exact binomial p-value, the odds ratio, and a significance flag at alpha 0.05.

  • Comparing two diagnostic tests on the same patients: Run both tests on every patient and ask whether the positive-call rate differs.
  • Before-after study with binary outcomes: Measure the same yes/no outcome before and after an intervention.
  • A/B test with paired responses: Show the same user both UI versions and test whether conversion differs.
  • Survey responses at two time points: Record the same binary outcome on the same people at time 1 and time 2.

The test only uses the two off-diagonal cells, b and c; the diagonal cells a and d contribute no information because they cannot produce a discordant observation. The discordant total n = b + c is the effective sample size. When n is large (above about 25), the corrected statistic follows a chi-square distribution with 1 degree of freedom; when n is small, the exact binomial test is preferred. Per the R Project's mcnemar.test documentation, McNemar's chi-squared test checks symmetry of rows and columns in a two-dimensional contingency table, applying continuity correction in the 2-by-2 case.

For the broader effect-size framing (Cohen's d, Hedges' g, Glass's delta) used to grade practical importance, the Effect Size Calculator places the McNemars odds ratio in the same family.

How McNemar's Test Works

This McNemars test calculator reads the four cells, isolates the discordant total n = b + c, and computes the chi-square with and without continuity correction, plus the exact two-sided binomial p-value. The chi-square values are read against a chi-square distribution with one degree of freedom.

chi-square (no correction) = (b - c)^2 / (b + c) | chi-square (with correction) = (|b - c| - 1)^2 / (b + c) | exact two-sided p = 2 * min(P(X <= b), P(X >= b)), X ~ Bin(b + c, 0.5) | odds ratio = b / c | df = 1
  • a: Concordant pairs where both methods returned the same 'no' or control answer.
  • b: Discordant pairs where method 1 was 'yes' and method 2 was 'no'.
  • c: Discordant pairs where method 1 was 'no' and method 2 was 'yes'.
  • d: Concordant pairs where both methods returned the same 'yes' or treatment answer.

The minus-1 in the continuity correction is the Yates adjustment the chi-square test uses for a 2x2 table. It trades a small upward bias on the statistic for a less liberal p-value, which is the right trade when n is small.

When b + c is zero, the statistic is undefined. The page returns a 'cannot be computed' message and the exact binomial p-value defaults to 1.0 because the two methods agreed on every pair.

Worked example: paired diagnostic study with 12 and 5 discordant pairs

a = 50, b = 12, c = 5, d = 33 (100 paired observations, 17 discordant).

With continuity correction: (|12 - 5| - 1)^2 / 17 = 2.1176. Without correction: 2.8824. p (chi-square, 1 df) = 0.1456. p (exact) = 0.1435. Odds ratio = 2.4.

chi-square (corrected) = 2.1176, p (exact) = 0.1435, odds ratio = 2.4.

Both p-values sit above 0.05, so the two methods do not differ significantly. The odds ratio of 2.4 hints method 1 calls 'yes' more often, but the small discordant count means the evidence is weak.

According to GraphPad: McNemar's test, the exact two-sided p-value for McNemar's test is the two-sided binomial probability with p = 0.5 and n = b + c trials, which is preferred when the number of discordant pairs is small.

For a related test on a 2x2 table that uses the same observed-versus-expected structure, the Chi-Square Calculator returns the standard chi-square statistic and p-value without the paired-data framing.

Key Concepts Explained

Four ideas are the vocabulary you need to read this calculator's result out loud. Skim the names, then read the explanations once you have a table to look at.

Discordant vs concordant pairs

Concordant pairs sit on the diagonal (a and d): both methods agreed. Discordant pairs sit on the off-diagonal (b and c): the two methods disagreed. The test only uses the discordant cells, so the effective sample size is b + c.

Chi-square with continuity correction

The corrected statistic (|b - c| - 1) squared divided by (b + c) is the conservative version. The minus-1 is the Yates adjustment for a 2x2 chi-square test and keeps the test from being too liberal when n is small.

Exact binomial p-value

When n is small (often fewer than 25), the exact two-sided binomial p-value is preferred. It treats b as a Bin(n, 0.5) observation with n = b + c and reports 2 * min(P(X <= b), P(X >= b)). It stays valid when n is too small for the chi-square approximation.

Odds ratio of discordant cells

The odds ratio b over c summarizes the effect: 1 means equal disagreement, above 1 means method 1 calls 'yes' more often, below 1 means the opposite. The 95% CI uses sqrt(1/b + 1/c) on the log scale.

Once you can name these four ideas, the rest of the McNemar vocabulary - the Edwards correction, the marginal homogeneity test, the Cochran Q test for more than two time points - is a small variation on the same building blocks.

When n is small, the chi-square approximation can give a p-value that is too small, which is why the P-Value Calculator includes the exact binomial alternative this page also reports.

How to Use This Calculator

Five steps take you from a paired data table to a McNemar chi-square, an exact binomial p-value, and an odds ratio with a 95% CI. The McNemars test calculator walks you through each step below.

  1. 1 Lay out your paired observations in a 2x2 table: Count the pairs in each cell. a and d are concordant; b and c are discordant. Put method 1 on the rows and method 2 on the columns.
  2. 2 Enter the four cell counts: Type the integer count of each cell into the matching input. The page rounds down any decimal so the four counts describe a real paired sample.
  3. 3 Read the chi-square and the exact binomial p-value together: The result panel shows the chi-square with and without continuity correction, the p-value against a chi-square with 1 df, and the exact two-sided binomial p-value. When n is small, treat the exact binomial p-value as primary.
  4. 4 Read the odds ratio and its 95% CI: The odds ratio b over c summarizes how often method 1 disagrees in the 'b' direction versus the 'c' direction. The 95% CI uses sqrt(1/b + 1/c) on the log scale; it is undefined when c is zero.
  5. 5 Compare the p-value to alpha 0.05: The significance flag at the bottom tells you whether the p-value is below 0.05. Use it to write 'the two methods differ' or 'no significant difference' in your results.

Read off a = 50, b = 12, c = 5, d = 33 from a paired diagnostic study, type them in, and the calculator reports chi-square (corrected) = 2.1176, p (exact) = 0.1435, odds ratio = 2.4 (95% CI 0.846 to 6.813). The p-value sits above 0.05, so the two methods do not differ, and the odds ratio shows a small numerical edge for method 1.

For a paired comparison on a continuous outcome rather than a binary one, the T-Test Calculator uses the same idea of within-pair differences on a numerical scale.

Benefits of Using This Calculator

Concrete benefits students, instructors, and applied researchers report from running the McNemars test through a single page instead of a stats package.

  • Reads the full 2x2 table, not just b and c: Enter all four cells at once; the page shows the discordant total in the result panel.
  • Reports both chi-square versions and the exact p-value: Corrected and uncorrected chi-square sit next to each other so you can see the size of the Yates adjustment, and the exact binomial p-value is shown so you can defend the result for small n.
  • Includes the odds ratio with a 95% CI: Result panel adds b over c with a log-scale confidence interval so you can quote the effect size alongside the significance flag, instead of reporting the p-value alone.
  • Flags the divide-by-zero cases explicitly: When b + c is zero, the page returns a clear 'cannot be computed' message and a p-value of 1.0, instead of NaN. The same protection applies to c = 0 for the odds ratio.
  • Pairs naturally with the chi-square and confusion matrix calculators: Cross-links move you between the three without retyping the four counts.

A study that uses this test usually also reports a confusion matrix, and the Confusion Matrix Calculator turns the same four cells into accuracy, precision, recall, F1, and the Matthews correlation coefficient.

Factors That Affect Your Results

Three factors drive which McNemar output to report, and two limitations remind you that the test is paired and binary.

Size of the discordant total n = b + c

When n is small (often fewer than 25), the chi-square approximation can overstate significance and the exact binomial p-value is more reliable. When n is large, the chi-square version is fine.

Direction and balance of the discordant cells

A 12 to 5 split (b larger) means method 1 calls 'yes' more often than method 2. The odds ratio encodes direction; chi-square alone only encodes how lopsided the split is.

Choice of the alpha threshold

The significance flag uses alpha = 0.05 by default. For confirmatory analyses with small discordant counts, an exact binomial p-value below 0.01 is often required.

Layout of the 2x2 table

Swapping row and column labels flips b with c, which changes the sign of the odds ratio but leaves the chi-square unchanged. Pick a layout where b represents the direction you want to test.

  • The test is for paired binary data and does not generalize to more than two measurements per subject; the related Cochran Q test handles three or more paired binary outcomes.
  • The test only uses the discordant cells, so two studies with the same b and c values produce the same p-value regardless of how large a and d are.

Per MedCalc: McNemar test on paired proportions, the two-sided p-value uses the cumulative binomial distribution, and the 95% confidence interval follows Sheskin (2011).

For a non-binary paired analysis on the same subjects, the Correlation Calculator reports Pearson, Spearman, and Kendall agreement on two paired columns of numbers.

McNemars test calculator with paired 2x2 table inputs a, b, c, d and chi-square, exact binomial p-value, odds ratio, and significance flag outputs
McNemars test calculator with paired 2x2 table inputs a, b, c, d and chi-square, exact binomial p-value, odds ratio, and significance flag outputs

Frequently Asked Questions

Q: What is McNemar's test used for?

A: McNemar's test is a non-parametric test for paired nominal data, most often a 2x2 table of before-after or method-A versus method-B outcomes on the same subjects. It tests whether the marginal probabilities of the two outcomes differ.

Q: How do you find the discordant pairs b and c?

A: Lay the paired data in a 2x2 table with method 1 on the rows and method 2 on the columns. b is the off-diagonal cell where method 1 was 'yes' and method 2 was 'no', and c is the other off-diagonal cell. The concordant cells a and d do not enter McNemars test.

Q: What is the difference between McNemar's test with and without continuity correction?

A: The continuity-corrected version is (|b - c| - 1) squared divided by (b + c); the uncorrected version is (b - c) squared divided by (b + c). The minus-1 is the same Yates adjustment used in the 2x2 chi-square test and keeps the corrected test from being too liberal when n is small.

Q: When should I use the exact binomial version of McNemar's test?

A: Use the exact binomial p-value when the discordant total n = b + c is small, often fewer than 25. The exact two-sided p-value is 2 times the smaller of P(X <= b) and P(X >= b) with X drawn from a Bin(n, 0.5) distribution.

Q: How do you interpret the McNemar chi-square p-value?

A: A McNemar chi-square p-value below your chosen alpha (commonly 0.05) means the two methods differ in how often they call the 'yes' outcome. The effect size is best read from the odds ratio b over c and its 95% confidence interval, not from the p-value alone.

Q: What is the odds ratio from McNemar's test?

A: The odds ratio is b divided by c. A value of 1 means the two methods disagree in each direction equally, a value above 1 means method 1 calls 'yes' more often than method 2, and a value below 1 means the opposite. The 95% confidence interval is undefined when c is zero.