Cochran's Q Test Calculator
Free Cochran's Q test calculator for 3 or more related groups with binary outcomes (yes/no, success/fail). Enter matched subjects across treatments, get Q statistic, degrees of freedom, chi-square p-value, assumptions and interpretation.
Each row represents one matched subject.
Each column represents one condition (k ≥ 3).
Fill each cell with 0 (failure) or 1 (success) for every subject & condition.
Q statistic
—
Higher values indicate more evidence of differing proportions.
Degrees of freedom
—
df = k − 1
p-value
—
Chi-square (upper tail) approximation.
Q compares the column totals and row-by-row agreement. The p-value comes from χ² with k − 1 degrees of freedom.
How to use this calculator
Enter the number of matched subjects and the treatments (k ≥ 3), build the data table, then fill each cell with 0 (failure) or 1 (success). When every cell is defined, the calculator estimates the Cochran's Q statistic, its degrees of freedom, and the chi-square p-value for the null hypothesis that the success proportion is equal across all conditions.
Methodology
The calculator aggregates row and column totals, computes the Q statistic from the Cochran's Q formula, and evaluates the chi-square upper tail to derive the p-value. The computation mimics the classical matrix-based derivation while guarding against invalid or degenerate tables.
Assumptions
- k ≥ 3 related groups sharing the same subjects.
- Binary outcomes (0 or 1) with no missing entries.
- Each subject is measured under every treatment.
Notation:
- n = number of matched subjects.
- k = number of treatments/conditions.
- Cj = column total for treatment j.
- Ri = row total for subject i.
- T = total number of successes = Σ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, Q ~ χ²(k − 1).
Post-hoc?
Cochran's Q only signals that at least two conditions have different proportions. To identify the specific pairs, run pairwise McNemar tests with a multiple-comparisons correction (Bonferroni, Holm, etc.).
Full original guide (expanded)
Related nonparametric (related samples)
Notes
- Use for matched dichotomous data with ≥3 conditions.
- If p < 0.05 → reject equal proportions.
- Follow up with pairwise McNemar + correction.
About the author
Ugo Candido builds statistical tools and educational explanations so readers can replicate the formulas and understand assumptions.
Editorial policy
CalcDomain content is reviewed for clarity, accuracy, and transparency. We do not accept paid placements that influence calculator outputs, and we display inputs and assumptions directly in the interface so you can verify every number.