Paired χ²: McNemar / Cochran's Q
Compare paired binary outcomes on the same subjects — e.g. positive rates of two tests in the same patients, or before/after positive rates. Two conditions use McNemar (paired 2×2); three or more use Cochran's Q. The ordinary chi-square assumes independence and is wrong for paired data. Computed locally; data never uploaded.
① Input
Paired counts: rows = test 1, columns = test 2. b and c are the discordant pairs (McNemar uses only these).
| Test 2 + | Test 2 − | |
|---|---|---|
| Test 1 + | ||
| Test 1 − |
How to use & methodology
When McNemar instead of the ordinary chi-square?
When the data are paired/correlated — two measurements on the same subjects or two methods (e.g. the same patients undergo tests A and B). The ordinary chi-square assumes the two groups are independent and gives wrong conclusions on paired data. McNemar looks only at the discordant pairs.
Why an exact binomial p?
With few discordant pairs the chi-square approximation is poor. McNemar essentially tests the binomial hypothesis that b makes up half the discordant pairs, so an exact binomial test can be used, which is more reliable at small samples. This tool recommends it when discordant pairs are <25.
What to do after a significant Cochran's Q?
It means at least two conditions have different positive rates. Run pairwise McNemar tests to locate the differences, and correct for multiple comparisons (e.g. Benjamini–Hochberg, see the multiple-testing correction tool).
Can it compare continuous before/after change?
No. McNemar/Q are for binary outcomes. For paired/before-after comparison of a continuous variable use the paired t-test (t-test tool) or Wilcoxon signed-rank (non-parametric tool).