Cochran's Q Test Calculator

Test whether the success proportion is the same across 3 or more related treatments (or time points), when the outcome is binary (0/1, yes/no) and measured on the same subjects. This is the natural extension of the McNemar test to k > 2 conditions.

each row = one subject

each column = treatment

Q statistic

Higher = more evidence of difference

df

df = k − 1

p-value

Chi-square approximation

How Cochran's Q test works

Suppose you test the same subjects under k different conditions, and for each condition the outcome is success (1) or failure (0). You want to know if the success rate is the same for all k conditions.

Notation:

  • k = number of treatments/conditions
  • n = number of subjects (matched)
  • Cj = column total for treatment j (sum over subjects)
  • Ri = row total for subject i (how many successes that subject had across all treatments)
  • T = total number of successes over all cells = ΣCj

Test statistic:

\( Q = \frac{(k-1)\left[k \sum_{j=1}^{k} C_j^2 - T^2 \right]}{kT - \sum_{i=1}^{n} R_i^2} \)

Under the null hypothesis (all proportions equal), Q ~ χ² with k − 1 degrees of freedom.

Assumptions

  • k ≥ 3 related groups (matched, same subjects)
  • Binary outcome (0/1)
  • No missing cells (every subject measured in every condition)

Post-hoc?

Cochran's Q only tells you that at least two conditions differ. To see which ones differ, you can run pairwise McNemar tests with a multiple-comparisons adjustment (Bonferroni, Holm).


Audit: Complete
Formula (LaTeX) + variables + units
This section shows the formulas used by the calculator engine, plus variable definitions and units.
Formula (extracted LaTeX)
\[','\\]
','\
Formula (extracted text)
Notation: k = number of treatments/conditions n = number of subjects (matched) Cj = column total for treatment j (sum over subjects) Ri = row total for subject i (how many successes that subject had across all treatments) T = total number of successes over all cells = ΣCj Test statistic: \( Q = \frac{(k-1)\left[k \sum_{j=1}^{k} C_j^2 - T^2 \right]}{kT - \sum_{i=1}^{n} R_i^2} \) Under the null hypothesis (all proportions equal), Q ~ χ² with k − 1 degrees of freedom.
Variables and units
  • No variables provided in audit spec.
Sources (authoritative):
Changelog
Version: 0.1.0-draft
Last code update: 2026-01-19
0.1.0-draft · 2026-01-19
  • Initial audit spec draft generated from HTML extraction (review required).
  • Verify formulas match the calculator engine and convert any text-only formulas to LaTeX.
  • Confirm sources are authoritative and relevant to the calculator methodology.
Verified by Ugo Candido on 2026-01-19
Profile · LinkedIn
, ', svg: { fontCache: 'global' } }; ]], displayMath: [['\\[','\\]']] }, svg: { fontCache: 'global' } };, svg: { fontCache: 'global' } };