Advertisement

McNemar's test calculator

Enter a paired before/after or matched-classification table. Only the two discordant cells determine the test statistic.

Calculator

McNemar chi-square statistic
4.083333
Discordant pairs
12.000000
Two-sided p-value
4.3308142811%
Decision
Reject the null hypothesis
Paired classification counts
BeforePositive afterNegative after
Positive before20.00000010.000000
Negative before2.00000030.000000

Advertisement

How this calculator works

The null hypothesis gives the two directions of change equal probabilities. Conditional on the discordant total, either direction has probability one half. The exact method doubles the smaller binomial tail and caps the result at one. Mid-p subtracts one probability mass at the observed discordant count from that doubled tail; it reduces conservatism but does not have the same exact size guarantee. The asymptotic methods compare the squared discordance difference with chi-square on one degree of freedom. Choose an explicit continuity subtraction of one (Edwards) or one half. Both are floored at zero; software naming conventions vary, so compare the formula rather than the name alone. With no discordant pairs, this tool reports statistic zero and p = 1.

Formula

Uncorrected χ² = (b - c)²/(b + c). Corrected χ² = max(0, |b - c| - 1)²/(b + c). Exact p = min(1, 2P[B ≤ min(b,c)]), B ~ Binomial(b + c, 0.5). Mid-p = min(1, 2P[B ≤ min(b,c)] - P[B = min(b,c)]).

Worked example

For b = 10 and c = 2 there are 12 discordant pairs, uncorrected chi-square is 16/3 and corrected chi-square is 49/12. The exact two-sided p is 79/2048 = 0.03857421875.

Advertisement

Frequently asked questions

Why do the diagonal cells not affect p?

They record pairs that did not change category. The null comparison concerns the direction of discordant pairs.

When is exact inference useful?

It avoids the chi-square approximation when the number of discordant pairs is small.

Are the two samples independent?

The observations within each pair are linked. Different pairs should be independent of one another.

Sources

Advertisement