Cochran's Q test

This page offers all the basic information you need about the cochran's q test. It is part of Statkat’s wiki module, containing similarly structured info pages for many different statistical methods. The info pages give information about null and alternative hypotheses, assumptions, test statistics and confidence intervals, how to find p values, SPSS how-to’s and more.

To compare the cochran's q test with other statistical methods, go to Statkat's or practice with the cochran's q test at Statkat's

Contents

When to use?

Deciding which statistical method to use to analyze your data can be a challenging task. Whether a statistical method is appropriate for your data is partly determined by the measurement level of your variables. The cochran's q test requires the following variable types:

Variable types required for the cochran's q test :
Independent/grouping variable:
One within subject factor ($\geq 2$ related groups)
Dependent variable:
One categorical with 2 independent groups

Note that theoretically, it is always possible to 'downgrade' the measurement level of a variable. For instance, a test that can be performed on a variable of ordinal measurement level can also be performed on a variable of interval measurement level, in which case the interval variable is downgraded to an ordinal variable. However, downgrading the measurement level of variables is generally a bad idea since it means you are throwing away important information in your data (an exception is the downgrade from ratio to interval level, which is generally irrelevant in data analysis).

If you are not sure which method you should use, you might like the assistance of our method selection tool or our method selection table.

Null hypothesis

The cochran's q test tests the following null hypothesis (H0):

H0: $\pi_1 = \pi_2 = \ldots = \pi_I$

Here $\pi_1$ is the population proportion of 'successes' for group 1, $\pi_2$ is the population proportion of 'successes' for group 2, and $\pi_I$ is the population proportion of 'successes' for group $I.$
Alternative hypothesis

The cochran's q test tests the above null hypothesis against the following alternative hypothesis (H1 or Ha):

H1: not all population proportions are equal
Assumptions

Statistical tests always make assumptions about the sampling procedure that was used to obtain the sample data. So called parametric tests also make assumptions about how data are distributed in the population. Non-parametric tests are more 'robust' and make no or less strict assumptions about population distributions, but are generally less powerful. Violation of assumptions may render the outcome of statistical tests useless, although violation of some assumptions (e.g. independence assumptions) are generally more problematic than violation of other assumptions (e.g. normality assumptions in combination with large samples).

The cochran's q test makes the following assumptions:

Test statistic

The cochran's q test is based on the following test statistic:

If a failure is scored as 0 and a success is scored as 1:

$Q = k(k - 1) \dfrac{\sum_{groups} \Big (\mbox{group total} - \frac{\mbox{grand total}}{k} \Big)^2}{\sum_{blocks} \mbox{block total} \times (k - \mbox{block total})}$

Here $k$ is the number of related groups (usually the number of repeated measurements), a group total is the sum of the scores in a group, a block total is the sum of the scores in a block (usually a subject), and the grand total is the sum of all the scores.

Before computing $Q$, first exclude blocks with equal scores in all $k$ groups.
Sampling distribution

Sampling distribution of $Q$ if H0 were true:

If the number of blocks (usually the number of subjects) is large, approximately the chi-squared distribution with $k - 1$ degrees of freedom
Significant?

This is how you find out if your test result is significant:

If the number of blocks is large, the table with critical $X^2$ values can be used. If we denote $X^2 = Q$:
Equivalent to

The cochran's q test is equivalent to:

Friedman test, with a categorical dependent variable consisting of two independent groups.
Example context

The cochran's q test could for instance be used to answer the question:

Subjects perform three different tasks, which they can either perform correctly or incorrectly. Is there a difference in task performance between the three different tasks?
SPSS

How to perform the cochran's q test in SPSS:

Analyze > Nonparametric Tests > Legacy Dialogs > K Related Samples...
Jamovi

How to perform the cochran's q test in jamovi:

Jamovi does not have a specific option for the Cochran's Q test. However, you can do the Friedman test instead. The $p$ value resulting from this Friedman test is equivalent to the $p$ value that would have resulted from the Cochran's Q test. Go to:

ANOVA > Repeated Measures ANOVA - Friedman