Site icon Codanics

McNemar Test and Cochran’s Q Calculator (Exact p)

McNemar Test and Cochran's Q Calculator: free online tool by Codanics that runs in your browser
Statistics

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.

✅ No login needed100% freeRuns in your browserYour data stays on your device
McNemar Test and Cochran's Q Calculator✅ Free · no login📚 Cite this tool
Your data never leaves your PC. Your data is analysed on your own computer or phone, even when you upload a CSV or Excel file. Nothing is uploaded, stored or seen by Codanics, and no login is needed.
After: YesAfter: No
Before: Yesab
Before: Nocd

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.

Citation · APA 7th edition

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.

🚀 Follow Codanics channel on WhatsApp for more updatesNew free tools, scholarships, PhD positions and research tips, straight to your phone. Free lessons on YouTube too.

How to use the McNemar Test and Cochran's Q Calculator

  1. 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).
  2. 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.
  3. For ratings with more than two categories (for example mild/moderate/severe rated twice), open McNemar–Bowker and paste the square table.
  4. 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.

DesignTest
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+ conditionsCochran’s Q, then pairwise McNemar tests
A nominal or ordinal rating with 3+ categories measured twiceMcNemar–Bowker test of symmetry
Two independent groupsChi-square or two-proportion test
Agreement between two raters (not change)Cohen’s kappa

Formulas

McNemar: χ² = (|b − c| − 1)² / (b + c) (without correction: (b − c)² / (b + c)), df = 1 Exact McNemar: two-sided binomial test of b successes in b + c trials with p = 0.5 Paired OR = b / c; p₁ − p₂ = (b − c) / N Cochran’s Q: Q = (k − 1) · [k·ΣCⱼ² − T²] / [k·T − ΣRᵢ²], df = k − 1 Cⱼ = column (condition) totals, Rᵢ = row (subject) totals, T = grand total McNemar–Bowker: χ² = Σ over i < j of (nᵢⱼ − nⱼᵢ)² / (nᵢⱼ + nⱼᵢ), df = number of pairs used

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.

A McNemar test showed a significant change in the proportion of symptom present from before treatment (46.0%) to after treatment (28.0%), χ²(1, N = 100) = 9.03, p = .003, OR = 3.57, 95% CI [1.50, 9.78].

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.
Learn the statistics behind these numbers. Codanics has free statistics, R and Python lessons on YouTube and full courses for researchers.

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

Made by Dr. Muhammad Aammar Tufail, Codanics. First published 17 November 2026, last updated 16 November 2026. Found a bug or have an idea for a new tool? Tell us on the WhatsApp channel or in the comments on YouTube. Results are for learning and planning; check important analyses with a statistician or your supervisor.
Exit mobile version