QTEST
Performs a Cochran Q test for related observations.
Required Arguments
X — NOBS by NVAR matrix of dichotomized data, containing NOBS readings of zero or one on each of NVAR treatments. (Input)
Q — Cochran’s Q statistic. (Output)
PQ — Asymptotic probability of exceeding Q under the null hypothesis of equality of the underlying populations. (Output)
Optional Arguments
NOBS — Number of blocks for each treatment. (Input)
Default: NOBS = size (X,1).
NVAR — Number of treatments. (Input)
Default: NVAR = size (X,2).
LDX — Leading dimension of X exactly as specified in the dimension statement in the calling program. (Input)
Default: LDX = size (X,1).
FORTRAN 90 Interface
Generic: CALL QTEST (X, Q, PQ [, …])
Specific: The specific interface names are S_QTEST and D_QTEST.
FORTRAN 77 Interface
Single: CALL QTEST (NOBS, NVAR, X, LDX, Q, PQ)
Double: The double precision name is DQTEST.
Description
Routine QTEST 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 (= 1.0) or failure (= 0.0). Within each block a multivariate vector of 1’s or 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(= NVAR) is the number of treatments.
The null hypothesis is rejected if Cochran’s Q statistic is too large.
Comments
1. Informational errors
Type | Code | Description |
---|
4 | 5 | X must consist of zeros and ones only. |
3 | 6 | X consists of either all ones or all zeros. Q is set to NaN (not a number). PQ is set to 1.0. |
2. The input data must consist of zeros and ones only. For example, the data may be passfail information on NVAR questions asked of NOBS people or the test responses of NOBS individuals to NVAR different conditions.
3. The resulting statistic is distributed approximately as chi‑squared with NVAR ‑ 1 degrees of freedom if NOBS is not too small. NOBS greater than or equal to 5 * NVAR is a conservative recommendation.
Example
The following example is taken from Siegel (1956, page 164). It measures the responses of 18 housewives to 3 types of interviews.
USE QTEST_INT
USE UMACH_INT
IMPLICIT NONE
INTEGER LDX, NVAR
PARAMETER (NVAR=3, LDX=18)
!
INTEGER NOUT
REAL PQ, Q, X(LDX,NVAR)
!
DATA X/0, 1, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, &
1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, &
0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0/
! Perform Cochran Q test
CALL QTEST (X, Q, PQ)
! Print results
CALL UMACH (2, NOUT)
WRITE (NOUT,99999) Q, PQ
!
99999 FORMAT (' Q = ', F6.3, /, ' PQ = ', F9.5)
!
END
Output
Q = 16.667
PQ = 0.00024