Editverse Free Calculator

McNemar’s Test Calculator

Compare two paired proportions — the same subjects measured twice — with the test statistic, the p-value, and the reproducible R command. Read a full interpretation guide below. Validated against R 4.3.3.

In Simple Words

McNemar’s test compares two related yes/no measurements on the same subjects — for example, a symptom present before and after treatment, or two tests run on every patient. Because the two measurements are paired, an ordinary chi-square test is not valid; McNemar’s focuses only on the subjects who changed.

It looks at the two “discordant” cells of a 2×2 paired table: those who were positive at first and negative later, and those who went the other way. If change happens equally in both directions, there is no real effect; a strong imbalance between the two discordant cells is what McNemar’s test detects.

When to Use McNemar’s Test

Use it for paired binary data: before-and-after measurements on the same people, matched case-control pairs, or two diagnostic tests applied to every subject. The question is whether the proportion positive changed, accounting for the fact that the two measurements come from the same individuals.

If your two groups are independent rather than paired, use the chi-square test or, for small samples, Fisher’s exact test instead. When the number of discordant pairs is small, use the exact binomial version of McNemar’s test rather than the chi-square approximation. Report the proportions changing in each direction along with the p-value. Not sure whether your design is paired? Our interactive Test Selector can help.

McNemar's Test Paired binary outcomes (before/after) · validated vs R 4.3.3
User guide

When to use. Compare paired binary outcomes (the same subjects before/after, or matched case-control pairs).

Assumptions. Pairs are independent of each other; the outcome is dichotomous at both time points; only discordant pairs carry information.

Common mistakes. Do not use for independent groups (use chi-square or Fisher). With fewer than ~25 discordant pairs prefer the exact p-value.

Worked example

Click Load example data above, then Run Analysis to see a fully worked result with figure, formula and interpretation for this test.

References
  1. McNemar Q. Note on the sampling error of the difference between correlated proportions. Psychometrika. 1947;12(2):153-157.
  2. Fagerland MW, Lydersen S, Laake P. The McNemar test for binary matched-pairs data. BMC Med Res Methodol. 2013;13:91.

Worked Examples

Example 1 — Before-and-after treatment

Suppose 40 patients are scored positive or negative for a symptom before and after therapy. McNemar’s test ignores those who stayed the same and compares the number who improved (positive→negative) with the number who worsened (negative→positive). A large imbalance between these two counts signals a real change.

Example 2 — Few discordant pairs

If only a handful of subjects changed, the chi-square form of the test is unreliable. The exact binomial version computes the probability directly and should be reported instead, much as Fisher’s exact test replaces chi-square for sparse unpaired tables.

Assumptions to Check

Paired observations. The two measurements must come from the same subjects (or matched pairs). For independent groups, McNemar’s is the wrong test.

Binary outcome. Each measurement is one of two categories. For more than two categories on paired data, an extension such as the Stuart-Maxwell test is needed.

Adequate discordant counts. The chi-square approximation needs a reasonable number of discordant pairs; when that number is small, switch to the exact binomial test.

Common Mistakes

Using chi-square on paired data

An ordinary chi-square test assumes independent groups and is invalid for repeated measurements on the same subjects. McNemar’s is the correct paired test.

Including the concordant cells

Subjects who gave the same answer both times carry no information about change. McNemar’s test deliberately uses only the two discordant cells.

Using the approximation with few discordants

When the discordant total is small, the chi-square version is inaccurate. Use the exact binomial McNemar’s test instead.

Reporting only the p-value

State how many subjects changed in each direction and the proportions involved, so readers see the direction and size of the shift, not just significance.

Frequently Asked Questions

How is McNemar’s test different from chi-square?

Chi-square compares two independent groups; McNemar’s compares two paired measurements on the same subjects and uses only the discordant pairs.

When should I use the exact version?

When the number of discordant pairs is small (roughly under 25), the exact binomial test is more reliable than the chi-square approximation.

Can McNemar’s test handle more than two categories?

Not directly. For paired data with several categories, use an extension such as the Stuart-Maxwell or Bhapkar test.

Does the result match SPSS, R, and Stata?

Yes. The calculator uses the standard McNemar computation as standard software and shows the exact R command so you can reproduce it.

References

  1. Hazra A, Gogtay N. Biostatistics series module 4: comparing groups — categorical variables. Indian J Dermatol. 2016;61(4):385–392. PMID 27512183.
  2. Roldán-Nofuentes JA. Compbdt: an R program to compare two binary diagnostic tests subject to a paired design. BMC Med Res Methodol. 2020;20(1):143. PMID 32503431.
  3. McNemar Q. Note on the sampling error of the difference between correlated proportions or percentages. Psychometrika. 1947;12(2):153–157.

Need This Analysis Done for Your Manuscript?

Our PhD biostatisticians analyse your paired categorical data, choose the exact or approximate test, and deliver publication-ready tables with reproducible R output.

Get Expert Statistical Help