Cochran's Q Test Calculator
Paste a table of 1s and 0s — one row per subject, one column per condition — and get Cochran's Q test of whether the proportion of successes is the same in every condition. The calculator shows Q, its degrees of freedom and p-value, Kendall's W, the success rate in each condition, and pairwise McNemar tests with Holm and Bonferroni adjustments, with the working laid out. Free, no sign-up.
0 subjects · 0 conditions
Enter at least two subjects and at least two conditions, coded 1 and 0.
How to Use the Cochran's Q Test Calculator
- 1. Code the outcomes. Use 1 for a success (yes, pass, present) and 0 for a failure, with one row per subject and one column per condition. Commas, spaces, or tabs work, so a block pasted from a spreadsheet is fine. A first line of words is read as the condition names.
- 2. Name the conditions. Optionally type the names, separated by commas, if your data has no header line.
- 3. Choose α. It sets the decision line under the results.
- 4. Read Q and the follow-ups. A significant Q means the success rate is not the same in every condition; the pairwise McNemar table shows which conditions differ. Copy the APA line when you are done.
What Cochran's Q Test Does
Cochran's Q is the test to reach for when the same subjects are measured on a yes/no outcome under three or more conditions: the same students answering questions in three formats, the same patients checked for a symptom at four visits, the same pages judged by several raters. It extends McNemar's test, which handles two conditions, and it is the binary counterpart of the Friedman test.
With n subjects, k conditions, column totals Cⱼ, row totals Rᵢ, and grand total T, Q = (k − 1)[k ΣCⱼ² − T²] / (k T − ΣRᵢ²). Under the null hypothesis that the success probability is the same in every condition, Q follows approximately a chi-square distribution with k − 1 degrees of freedom. Subjects who succeed in all conditions or fail in all of them are uninformative — they do not affect Q — so the effective sample is the set of subjects whose outcomes vary. The approximation is dependable when there are at least 4 informative subjects and n × k is at least 24 (Cochran, 1950); the calculator warns you otherwise.
Q is numerically identical to the tie-corrected Friedman statistic computed on the 0/1 table, so Kendall's W = Q / (n(k − 1)) serves as an effect size: 0 means the conditions are indistinguishable and 1 means every subject shows the same pattern of successes across the conditions.
Worked Example: Three Question Formats
Click Try an example to load results for 15 students, each of whom answered one question in three formats (1 = correct). Success rates are 5 of 15 for multiple choice (.33), 9 for short answer (.60), and 13 for essay (.87). Ten students are informative; the other five answered all correctly or all incorrectly.
Cochran's Q, step by step
T = 5 + 9 + 13 = 27; ΣCⱼ² = 25 + 81 + 169 = 275; ΣRᵢ² = 61
Q = 2 × [3 × 275 − 27²] / (3 × 27 − 61) = 2 × 96 / 20 = 9.6
df = 2, p = .0082; W = 9.6 / (15 × 2) = .32
Multiple choice vs essay: b = 0, c = 8, exact p = .0078, Holm-adjusted .023
In APA style: the proportion of correct answers differed by question format, Cochran's Q(2, N = 15) = 9.60, p = .008. Pairwise McNemar tests with a Holm adjustment show that essay questions were answered correctly more often than multiple-choice questions (adjusted p = .023); the other two pairs did not differ (adjusted p = .438).
Cochran's Q or Another Test?
| Situation | Better choice |
|---|---|
| Same subjects, yes/no outcome, two conditions | McNemar's test |
| Same subjects, yes/no outcome, three or more conditions | Cochran's Q |
| Same subjects, numeric or ranked scores, three or more conditions | Friedman test or repeated measures ANOVA |
| Different subjects in each group, yes/no outcome | Chi-square test |
| Different subjects, small counts, two groups | Fisher's exact test |
Frequently Asked Questions
- When should I use Cochran's Q test?
- Use it when the same subjects, or matched sets of subjects, are measured on a binary outcome under three or more conditions. It tests whether the proportion of successes differs between the conditions while respecting the pairing. For two conditions it reduces to McNemar's test.
- What post hoc test follows a significant Cochran's Q?
- The usual follow-up is a McNemar test for each pair of conditions, with a Bonferroni or Holm correction for the number of pairs. The calculator gives the exact p-value from the discordant subjects, plus the continuity-corrected chi-square p-value, adjusted by both methods.
- How do I report Cochran's Q in APA style?
- Report Q with its degrees of freedom and the number of subjects, then the p-value: Cochran's Q(2, N = 15) = 9.60, p = .008. Give the success rate in each condition and the pairwise McNemar results, and say which adjustment you used. Italicise Q, N, and p.
- Why are some subjects ignored?
- A subject with the same outcome in every condition provides no information about differences between conditions, so it contributes nothing to Q. They still count in the success rates and in n, but a table with few subjects whose outcomes vary has little power, however large it looks.
- How many subjects do I need?
- Cochran's guideline is at least 4 informative subjects and n × k of at least 24 for the chi-square approximation to be dependable. With fewer, the p-value can be off; an exact permutation version of the test is the alternative, or McNemar's exact test on pairs of conditions.
- What is the difference between Cochran's Q and the Friedman test?
- They are the same calculation for different data. The Friedman test ranks numeric scores within each subject; applied to a table of 0s and 1s, with ties handled by the standard correction, it gives exactly Cochran's Q. Cochran's Q is the name used when the data are binary.