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.
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: approve | Second: disapprove | |
|---|---|---|
| First: approve | 794 | 150 |
| First: disapprove | 86 | 570 |
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
- R reference example output, stats-Ex.Rout.save checked November 21, 2026