COCHRANQ Function
Performs a Cochran Q test for related observations.
Usage
result = COCHRANQ(x)
Input Parameters
x—Two-dimensional array containing the matrix of dichotomized data.
Returned Value
result—The p-value for the Cochran Q statistic.
Input Keywords
Double—If present and nonzero, double precision is used.
Output Keywords
Q—Named variable into which the Cochran’s Q statistic is stored.
Discussion
Function COCHRANQ 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
1. The blocks are a random sample from the population of all possible blocks.
2. The outcome of each treatment is dichotomous.
Hypothesis
The hypothesis being tested may be stated in at least two ways.
1. H0 : All treatments have the same effect.
H1 : The treatments do not all have the same effect.
2. 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
1. 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.
2. 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 × 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  =  COCHRANQ(x)
PRINT, 'pq =', pq
; PV-WAVE prints: pq =  0.000240266
Warning Errors
STAT_ALL_0_OR_1x” 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_VALUESx(#, #)” = #. “x” must consist of zeros and ones only.