McNemar Test and Cochran's Q Calculator for Paired Yes/No Data
Use these tests when the same subjects give a yes/no answer more than once, for example whether a symptom is present before and after treatment, or whether two diagnostic tests agree on the same patients. McNemar’s test compares two paired proportions (with the exact version for small counts), McNemar–Bowker extends it to more than two categories, and Cochran’s Q compares three or more conditions.
| After: Yes | After: No | |
|---|---|---|
| Before: Yes | a | b |
| Before: No | c | d |
Only the discordant pairs (b and c) carry information about change. Have raw data? Use the Cochran’s Q tab with two columns, or paste the two columns there.
- PriceFree, no login or sign-up needed
- Your dataProcessed in your browser, never uploaded
- Works onPhone, tablet or computer, any modern browser
- Made byDr. Muhammad Aammar Tufail, Codanics
- Published17 November 2026
- Last updated16 November 2026
📚 How to cite this tool
This tool is free. If it helped your thesis, paper, report or assignment, please cite it. It keeps the tools free and helps other students find them.
Tufail, M. A. (2026). McNemar test and Cochran's Q calculator [Online tool]. Codanics. Retrieved 16 November 2026, from https://codanics.com/tools/mcnemar-test-calculator/
In-text citation: (Tufail, 2026) · Narrative: Tufail (2026)
The access date is today’s date, filled in automatically. Author: Muhammad Aammar Tufail. Published 17 November 2026.
How to use the McNemar Test and Cochran's Q Calculator
- For two paired measurements, stay on McNemar (2 × 2), name the two measurements and the outcome, and type the four counts: yes–yes (a), yes–no (b), no–yes (c) and no–no (d).
- For three or more conditions, open Cochran’s Q and paste one row per subject with a 1/0 (or yes/no) column per condition, or upload the sheet from Excel.
- For ratings with more than two categories (for example mild/moderate/severe rated twice), open McNemar–Bowker and paste the square table.
- Click Run test, read the p-value (the exact p is used automatically when there are fewer than 25 discordant pairs) and copy the APA sentence and table.
When to use McNemar’s test and Cochran’s Q
Both tests are for paired (dependent) nominal data: the same people, plants or samples are classified more than once. Using an ordinary chi-square test or a two-proportion test on such data is a common mistake, because it ignores the pairing.
| Design | Test |
|---|---|
| Yes/no measured twice on the same subjects (before/after, two tests on the same patients) | McNemar’s test |
| Yes/no measured three or more times, or under 3+ conditions | Cochran’s Q, then pairwise McNemar tests |
| A nominal or ordinal rating with 3+ categories measured twice | McNemar–Bowker test of symmetry |
| Two independent groups | Chi-square or two-proportion test |
| Agreement between two raters (not change) | Cohen’s kappa |
Formulas
Only discordant pairs (subjects who changed) enter McNemar’s test. When b + c is small (under about 25), the χ² approximation is unreliable and the exact binomial test is preferred; the tool switches to it automatically and lists both.
Worked example
100 patients were checked for a symptom before and after treatment: 21 had it both times (a), 25 lost it (b), 7 developed it (c) and 47 never had it (d). Prevalence fell from 46% to 28%. McNemar’s χ²(1) = 9.03 with continuity correction, p = .003; the exact test gives p = .002. The paired odds ratio is 25/7 = 3.57.
Assumptions
- The pairs (or subjects) are independent of each other.
- Each subject is measured under every condition (no missing values; rows with gaps are skipped in Cochran’s Q).
- For the χ² versions, enough discordant pairs; otherwise use the exact p-value.
Frequently asked questions
Why not use a normal chi-square test for before/after data?
Because the two measurements come from the same subjects, they are not independent. The ordinary chi-square test assumes independent groups and gives wrong p-values for paired data. McNemar’s test uses only the subjects who changed, which correctly accounts for the pairing.
Should I use the continuity correction or the exact test?
R’s mcnemar.test uses the continuity correction by default. With fewer than about 25 discordant pairs (b + c), the exact binomial version is recommended; the tool reports it and uses it as the main result in that case. The mid-p version is a less conservative alternative.
What post-hoc test follows a significant Cochran's Q?
Pairwise McNemar tests between conditions, with a correction for multiple comparisons. The tool uses exact McNemar tests with a Holm correction by default (Bonferroni or no correction are also available).
What effect size should I report for Cochran's Q?
A simple option is η²_Q = Q / (n(k − 1)) (Serlin, Carr and Marascuilo, 1982), which ranges from 0 to 1. For McNemar’s test, report the paired odds ratio b/c with its confidence interval, or the difference in proportions.
Can I use McNemar's test to compare two diagnostic tests?
Yes, if both tests were done on the same patients. McNemar’s test then compares the two tests’ positive rates (or sensitivities, if you use only the diseased patients).
Is my data uploaded?
No. Everything runs in your browser.
Do I need to log in or create an account to use the McNemar Test and Cochran's Q Calculator?
No. There is no login, no sign-up and no email required. Open the page and start using it straight away, for free, on any device.
How do I cite this tool in my thesis or paper?
Use the citation box on this page. In APA 7th edition: Tufail, M. A. (2026). McNemar test and Cochran's Q calculator [Online tool]. Codanics. Retrieved [date you used it], from https://codanics.com/tools/mcnemar-test-calculator/. BibTeX, RIS (EndNote, Mendeley, Zotero), MLA, Harvard, Chicago and Vancouver formats are also available.
Free guides and courses from Codanics
More free tools
See all free Codanics tools → · Codanics on YouTube · WhatsApp channel

