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).