McNemar's test calculator

Enter the four counts of a paired 2×2 table, such as the same people tested before and after, to see whether the proportion of yes answers changed. You get the chi-square test and the exact binomial p-value.

Between 0 and 1, usually 0.05. The result line uses the chi-square p-value.
χ² statistic4.05
p-value (χ²)0.04417
Result at α
p < α: the proportions differ significantly
p-value, exact binomial
0.04139
Degrees of freedom
1
Proportion yes on the 1st measurement
0.6
Proportion yes on the 2nd measurement
0.5
Difference (1st − 2nd)
0.1
Paired odds ratio (b/c)
3
Discordant pairs (b + c)
20
Total pairs
100

Fewer than 25 discordant pairs: the exact p-value is more reliable than the χ² one.

Runs in your browser: nothing you enter is sent anywhere.

How to use it

  1. Count the pairs in each cell of the table below.
  2. Enter a, b, c and d, and choose whether to use the continuity correction.
  3. Read χ², its p-value and the exact p-value.
2nd: yes 2nd: no
1st: yes a b
1st: no c d

Formulas

  • Without correction: χ² = (b − c)² ÷ (b + c)
  • With Edwards’ correction: χ² = (|b − c| − 1)² ÷ (b + c)
  • Both have 1 degree of freedom.
  • Exact p = 2 × P(X ≤ min(b, c)) for X ~ Binomial(b + c, ½), at most 1.
  • Proportions: 1st = (a + b)/n, 2nd = (a + c)/n; paired odds ratio = b/c.

Worked example

100 people asked before and after a campaign: 45 said yes both times, 15 changed from yes to no, 5 from no to yes, and 35 said no both times.

With the correction, χ² = (|15 − 5| − 1)² ÷ 20 = 81 ÷ 20 = 4.05, p = 0.044. The exact test: P(X ≤ 5) for 20 trials = (1 + 20 + 190 + 1140 + 4845 + 15 504) ÷ 2²⁰ = 21 700 ÷ 1 048 576 = 0.0207, so p = 2 × 0.0207 = 0.041. The share of yes fell from 60% to 50%.

Common mistakes

  • Entering group totals instead of paired counts. Each cell must count pairs, so a + b + c + d is the number of subjects, not of answers.
  • Using the test for independent groups; use Fisher’s exact test or chi-square there.

Frequently asked questions

When do I use McNemar's test?

When the same subjects give a yes/no answer twice, for example before and after a campaign, or two diagnostic tests on the same patients. Pairs are not independent, so a chi-square or Fisher test on the totals would be wrong.

Why do only b and c matter?

Pairs that answered the same both times (a and d) say nothing about change. The test asks whether changes from yes to no (b) are as common as changes from no to yes (c).

Should I use the continuity correction?

The corrected version, (|b − c| − 1)²/(b + c), is more conservative and is the default in many programs. With few discordant pairs the exact binomial p-value, shown on every result, is the better choice.

How is the exact p-value calculated?

Under the null hypothesis each discordant pair is equally likely to go either way, so b follows a binomial distribution with b + c trials and probability ½. The two-sided p is twice the probability of a count as small as the smaller of b and c, capped at 1.

More in Math

All tools in this category: Math ·Updated November 4, 2026

Privacy choices

Google Analytics shows us which tools are used and whether they work. It may set cookies. Your choice is kept in this browser.