- Introduced by
- William G. Cochran
- Year
- 1950
- Type
- Nonparametric proportions comparison
What does it do?
Cochran's Q test is a nonparametric hypothesis test, introduced by William G. Cochran in 1950, for comparing proportions across three or more related binary measurements.
It extends McNemar's test to the multiple-condition case and applies when every participant is observed under each condition and each outcome is recorded as success or failure (1/0).
The intuition behind the method
Imagine asking the same group of people whether they understand a concept after three different teaching methods, recording yes (1) or no (0) each time. Cochran's Q asks whether the proportion of 'yes' answers differs across the three methods, or whether the observed differences could plausibly be sampling noise. Because the same individuals appear in every condition, the test removes stable differences between people and focuses on whether the conditions themselves produce different success rates.
History
William G. Cochran introduced the Q statistic in his 1950 Biometrika paper, 'The comparison of percentages in matched samples', as a way to compare proportions across matched samples. It generalises McNemar's test, which handles two related binary measurements, to designs with three or more conditions. It is still used as the omnibus test for repeated binary measurements in several research fields.
When to use it
Use Cochran's Q test when you have a block (repeated-measures or matched) design with three or more conditions and a binary outcome. Every participant must contribute an observation under every condition, and the outcome must be genuinely dichotomous rather than collapsed from a continuous or ordinal variable. The test rests on three assumptions: subjects (blocks) are independent of one another; each subject is observed under all k conditions; and the outcome is coded identically in every condition, so that '1' means the same kind of success throughout. Because the same people pass through every condition, order or carryover effects can bias the comparison when one condition influences responses to the next. Counterbalancing the order of conditions or including a washout period between them reduces this risk. The chi-squared approximation is less reliable with small samples, so the number of subjects should be judged against this limitation. With only two conditions, McNemar's test is the appropriate choice. When the outcome is ordinal or continuous, Friedman's test is the nonparametric alternative to consider. If the design has missing observations for some subjects in some conditions, the block structure is broken and this test is not directly suitable.
Limitations and considerations
- Restricted to binary (0/1) outcomes; continuous, ordinal, or multi-category nominal outcomes require a different test.
- Requires a complete block design; missing data for any subject in any condition complicate the analysis.
- Because Q is referred to a chi-squared distribution only approximately, the approximation may be unreliable when the number of subjects is small or when success rates are very close to 0 or 1.
- A significant overall Q does not reveal which specific pairs of conditions differ; pairwise follow-up tests with multiplicity correction are needed.
Source conditions do not replace independent scientific review or validation by an analysis engine.
Strengths
- Applies directly to binary outcomes and does not require a normal distribution, which suits pass/fail or yes/no responses.
- Removes stable between-subject differences by using each participant as their own block, which can increase sensitivity to condition effects compared with treating the observations as independent groups.
- Extends the logic of McNemar's test to three or more conditions, so the two-condition and multi-condition analyses are easy to relate.
Applications
- Comparing the effectiveness of three or more instructional or therapeutic interventions on a pass/fail outcome in the same participant group.
- Testing whether a diagnostic criterion is met at multiple time points (e.g. before, immediately after, and six months after treatment) for the same patients.
- Evaluating whether the proportion of respondents endorsing an item changes across several survey waves or questionnaire formats administered to the same sample.
- Quality-control settings where the same items or units are inspected under different conditions and recorded as conforming (1) or non-conforming (0).
How it works
How it works
The null hypothesis states that the probability of a 'success' outcome is identical across all k conditions. The alternative hypothesis states that at least one condition has a different success rate. The test addresses all conditions simultaneously, so it does not assume any directional ordering among them.
Formula
H_0:\ p_1 = p_2 = \cdots = p_k \quad H_1:\ \text{at least one } p_j \text{ differs}The Q statistic is computed from column totals (Lⱼ, the number of successes in each condition) and row totals (Rᵢ, the number of successes across conditions for each subject). The numerator measures variation among the condition totals, scaled by k − 1, and the denominator reflects the within-subject pattern of successes. Under the null hypothesis, Q follows an approximate chi-squared distribution with k − 1 degrees of freedom.
Formula
Q = \frac{(k-1)\left[k\sum_{j=1}^{k}L_j^2 - \left(\sum_{j=1}^{k}L_j\right)^2\right]}{k\sum_{i=1}^{n}R_i - \sum_{i=1}^{n}R_i^2}If Q exceeds the chi-squared critical value with k − 1 degrees of freedom at the chosen significance level, the null hypothesis is rejected, indicating that the success proportions are not equal across all conditions. A significant result is normally followed by pairwise comparisons, most commonly repeated McNemar tests with a Bonferroni or Holm correction, to identify which conditions differ.
Formula
\text{reject } H_0 \text{ if } Q > \chi^2_{\alpha,\, k-1}Common pitfalls
- Applying Cochran's Q to a continuous or ordinal outcome that has been artificially dichotomised, rather than using Friedman's test.
- Ignoring the need for post-hoc pairwise comparisons after a significant Q and reporting only the omnibus result.
- Failing to correct for multiple comparisons when conducting follow-up McNemar tests, which inflates the family-wise error rate.
- Using the test when not every participant has an observation in every condition — the block structure is essential.
- Overlooking order or carryover effects when the same participants complete the conditions in a fixed sequence, so that differences reflect the sequence rather than the conditions themselves.
Frequently asked questions
How is Cochran's Q different from McNemar's test?
McNemar's test compares proportions across exactly two related binary measurements. Cochran's Q extends this to three or more conditions. With k = 2, Q reduces to the uncorrected McNemar chi-squared statistic, so the two approaches agree only when McNemar's test is used without a continuity correction.
What should I do after a significant Q?
Conduct pairwise McNemar tests for every pair of conditions and apply a multiplicity correction, such as Bonferroni (dividing α by the number of pairs) or the more powerful Holm step-down procedure, to control the family-wise error rate.
What if my outcome is not truly binary?
If the outcome is ordinal or continuous, use Friedman's test instead. Artificially collapsing a continuous variable into 0/1 to apply Cochran's Q discards information and is not recommended.
How large a sample do I need?
The chi-squared approximation can be unreliable with small samples or with extreme success rates (near 0% or 100%) in any condition. Rules of thumb for the minimum number of subjects vary and should not be applied mechanically, so judge adequacy against the size of the study and the observed success rates. When the number of subjects is small or some success rates are close to 0 or 1, an exact permutation version of the test or a simulation-based p-value is preferable.
Related methods
Sources
Cochran, W. G. (1950). The comparison of percentages in matched samples. Biometrika, 37(3–4), 256–266.
Open DOI reference