The IMSL_COCHRANQ function performs a Cochran Q test for related observations.
This routine requires an IDL Advanced Math and Stats license. For more information, contact your sales or technical support representative.
The IMSL_COCHRANQ function computes the Cochran Q test statistic that may be used to determine whether or not M matched sets of responses differ significantly among themselves. The data may be thought of as arising out of a randomized block design in which the outcome variable must be success or failure, coded as 1.0 and 0.0, respectively. Within each block, a multivariate vector of 1’s of 0’s is observed. The hypothesis is that the probability of success within a block does not depend upon the treatment.
Assumptions
- The blocks are a random sample from the population of all possible blocks.
- The outcome of each treatment is dichotomous.
Hypothesis
The hypothesis being tested may be stated in at least two ways.
-
H0 : All treatments have the same effect.
H1 : The treatments do not all have the same effect.
-
Let pij denote the probability of outcome 1.0 in block i, treatment j.
H0:pi1 = pi2 = ... = pic for each i.
H1:pij ≠ pik for some i, and some j ≠ k.
where c (equal to N_ELEMENTS(x(0, *))) is the number of treatments.
The null hypothesis is rejected if Cochrans’s Q statistic is too large.
Remarks
- The input data must consist of zeros and ones only. For example, let n_variables = N_ELEMENTS(x(0, *)) and n_observations = N_ELEMENTS(x(*, 0)), then the data may be pass-fail information on n_variables questions asked of n_observations people or the test responses of n_observations individuals to n_variables different conditions.
- The resulting statistic is distributed approximately as chi-squared with n_variables − 1 degrees of freedom if n_observations is not too small. N_observations greater than or equal to 5 x n_variables is a conservative recommendation.
Example
The following example is taken from Siegal (1956, p. 164). It measures the responses of 18 women to 3 types of interviews.
x = TRANSPOSE([[0.0, 0.0, 0.0], [1.0, 1.0, 0.0], $
[0.0, 1.0, 0.0], [0.0, 0.0, 0.0], $
[1.0, 0.0, 0.0], [1.0, 1.0, 0.0], $
[1.0, 1.0, 0.0], [0.0, 1.0, 0.0], $
[1.0, 0.0, 0.0], [0.0, 0.0, 0.0], $
[1.0, 1.0, 1.0], [1.0, 1.0, 1.0], $
[1.0, 1.0, 0.0], [1.0, 1.0, 0.0], $
[1.0, 1.0, 0.0], [1.0, 1.0, 1.0], $
[1.0, 1.0, 0.0], [1.0, 1.0, 0.0]])
pq = IMSL_COCHRANQ(x)
PRINT, 'pq =', pq
IDL prints:
pq = 0.000240266
Errors
Warning Errors
STAT_ALL_0_OR_1: “x” consists of either all ones or all zeros. “q” is set to NaN (not a number). “Result” is set to 1.0.
Fatal Errors
STAT_INVALID_X_VALUES: “x(#, #)” = #. “x” must consist of zeros and ones only.
Syntax
Result = IMSL_COCHRANQ(X [, /DOUBLE] [, Q=variable])
Return Value
The p-value for the Cochran Q statistic.
Arguments
X
Two-dimensional array containing the matrix of dichotomized data.
Keywords
DOUBLE (optional)
If present and nonzero, then double precision is used.
Q (optional)
Named variable into which the Cochran’s Q statistic is stored.
Version History