Chi-Square CalculatorChi-Square Calculator
Paired data

McNemar Test Calculator

Enter a 2x2 table of paired results, such as the same people asked twice. The McNemar test checks whether the proportion saying yes changed.

Second: approveSecond: disapprove
First survey: approve
First survey: disapprove
McNemar χ² with continuity correction16.8178
p-value (corrected)4.115 × 10−5
χ² without correction17.3559 (p 3.099 × 10−5)
Exact binomial p3.716 × 10−5

Discordant pairs: b = 150 and c = 86 (236 in all). Only these pairs carry information about a change; the 1,364 pairs that agree do not enter the test. df = 1.

p is below 0.05: evidence that the proportion changed between the two measurements, at the 5% level.

Reproduce this result in R or Python

R

tab <- matrix(c(794, 150, 86, 570), nrow = 2, byrow = TRUE)
mcnemar.test(tab)                  # with continuity correction (R default)
mcnemar.test(tab, correct = FALSE)
binom.test(150, 236, p = 0.5)     # exact version on the discordant pairs

Python (SciPy)

from scipy.stats import chi2, binomtest
b, c = 150, 86
x2_cc = (abs(b - c) - 1) ** 2 / (b + c)
print(x2_cc, chi2.sf(x2_cc, 1))           # with continuity correction
x2 = (b - c) ** 2 / (b + c)
print(x2, chi2.sf(x2, 1))
print(binomtest(b, b + c, 0.5).pvalue)     # exact version

Checked on November 21, 2026. Results computed by our statistics engine, version 1.0.0.

On this page

Why paired data need a different test

An ordinary chi-square test assumes every count is a separate, independent observation. When the same 1,600 people answer twice, each person appears in both measurements, so that assumption fails. The McNemar test puts each person in one cell according to both answers and looks only at the people who changed: b changed from yes to no, c from no to yes. If there were no overall change, b and c would be about equal.

The statistic is (b − c)² / (b + c) with 1 degree of freedom, or (|b − c| − 1)² / (b + c) with the continuity correction that R applies by default. For small numbers of changers, the exact version treats b as a binomial count out of b + c with probability one half.

Worked example: approval ratings

R's mcnemar.test example uses Agresti's data on 1,600 people asked in two surveys whether they approved of the president's performance (R reference output). It is pre-filled above.

Second: approveSecond: disapprove
First: approve794150
First: disapprove86570

150 people moved from approve to disapprove and 86 moved the other way. With the continuity correction χ² = (|150 − 86| − 1)² / 236 = 16.818 and p = 4.115 × 10−5, the same as R's printed output. Without the correction χ² = 17.356 (p = 3.099 × 10−5), and the exact binomial p is 3.716 × 10−5. All three show strong evidence that approval fell between the two surveys: from 59.0% to 55.0%.

Corrected, uncorrected or exact?

  • With many discordant pairs, as here, the three versions agree closely.
  • With few discordant pairs (a common rule of thumb is fewer than about 25), use the exact binomial p. The calculator warns when b + c is small.
  • Say which version you report. R prints the corrected one unless you set correct = FALSE.

Setting up the table

Rows are the first measurement and columns the second, in the same order (yes then no). The diagonal cells a and d hold the people whose answer did not change; they do not affect the test, but they matter for describing the size of the change. The test works for any paired yes or no data: the same patients before and after treatment, two diagnostic tests on the same samples, or matched case-control pairs.

If your two measurements come from different people, this is the wrong test: use the 2x2 calculator for independent groups.

Common questions

Why are the agreeing pairs ignored?

People who answered the same way both times give no information about whether the yes proportion changed. Only the changers can tip the balance.

Can I use McNemar for more than two categories?

Not directly. The Bowker test of symmetry extends it to larger square tables; it is not computed here.

Sources