1. Home
  2. QCOCHRAN procedure

QCOCHRAN procedure

Performs Cochran’s Q test for differences between related samples (D.A. Murray).

Options

PRINT = string token Controls printed output (test); default test
METHOD = string token Form of the test (exact, chisquare); default exac for small samples, otherwise chis
GROUPS = factor Defines the groups if there only one variable supplied for the DATA
STATISTIC = scalar Scalar to save the Q value
PROBABILITY = scalar Scalar to save the probability for the Q Test
MAXTIME = scalar Defines a limit for the maximum time for calculating the exact test; default * i.e. no limit.

Parameter

DATA = variates List of related samples, or variate containing all the samples (the GROUPS option must then be set to indicate the variable recorded in each unit belongs)

Description

Cochran’s Q test is an extension to the McNemar test for related samples that provides a method for testing for differences between three or more matched sets of frequencies or proportions. The matching samples can be based on k characteristics of N individuals that are associated with the response. Alternatively N individuals may be observed under k different treatments or conditions (e.g. different questions or one question at different times).

The data must be supplied as dichotomous variables containing 0 to represent failure (or absence), and 1 to represent success (or presence). The variables can be stored in separate variates and the DATA parameter set to list them all. Alternatively, all the data can be stored in a single variate, and the GROUPS option set to a factor to indicate which variable is recorded in each unit of the variate. (QCOCHRAN then assumes that the individuals are recorded in the same order for each variable.)

In its original form, the test leads to a chi-square test (see the Method section). However, this may be inaccurate when there are small numbers of subjects or samples. Consequently QCOCHRAN also provides an exact probability (based on the exact distribution of Q under a permutation model). The form of the test can be set to either chi-square or exact by using the METHOD option. The default is to use the exact test if the number of values in the samples is less than 4 and the product of this value with the number of samples is less than 24, otherwise the chi-square method is used. The Q statistic can be saved using the STATISTIC parameter, and the probability can be saved using the PROBABILITY parameter.

Although QCOCHRAN uses an efficient algorithm for calculating the exact probability, the time and memory required for this calculation can become impractible as the number of samples and values increases. Therefore, for large problems, the chi-square approximation should be used. However, for the exact calculation the MAXTIME option can be used to supply the maximum amount of time (in seconds) that will be used to calculate the exact probabilty. If this is time exceeded, the computation is terminated.

The PRINT option controls printed output, with settings:

    test the Q value and probability (the default).

Options: PRINT, METHOD, GROUPS, STATISTIC, PROBABILITY, MAXTIME.

Parameter: DATA.

Method

The Cochran Q Test is calculated by:

Q = (k × (k – 1) × ∑j=1…k{(TjTbar)2} ) / (k × ∑j=1…k{ui} – ∑j=1…k{ui2} )

where k is the number of samples, Tj is the sum of 1’s in the jth column, Tbar is the mean of the Tj‘s, and ui is the number of 1’s in the ith row. Under the null hypothesis this has an approximate chi-square distribution with (k-1) degrees of freedom.

The exact test is calculated using the permutation method of Patil (1975).

Action with RESTRICT

If a parameter is restricted the statistics will be calculated using only those units included in the restriction.

References

Patil K,D. (1975). Cochran’s Q Test: exact distribution. Journal of the American Statistical Association, 70, 186-189.

Siegel S. (1956). Nonparametric Statistics for the Behavioural Sciences. McGraw-Hill, New York.

See also

Procedures: CATRENDTEST, MCNEMAR.

Commands for: Basic and nonparametric statistics.

Example

CAPTION  'QCOCHRAN Example',\
      !t('Responses by housewives under 3 types of interview.',\
         'Data from Siegel (1956), Nonparametric Statistics for',\
         'the Behavioural Sciences, page 164.'); STYLE=meta,plain
VARIATE  [VALUES=0,1,0,0,1,1,1,0,1,0,1,1,1,1,1,1,1,1] Response1
&        [VALUES=0,1,1,0,0,1,1,1,0,0,1,1,1,1,1,1,1,1] Response2
&        [VALUES=0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,1,0,0] Response3
QCOCHRAN Response1,Response2,Response3
Updated on March 6, 2019

Was this article helpful?