Chapter 6: Nonparametric Statistics

cochran_q_test

Performs a Cochran Q test for related observations.

Synopsis

#include <imsls.h>

float imsls_f_cochran_q_test (int n_observations, int n_variables, float *x, ..., 0)

The type double function is imsls_d_cochran_q_test.

Required Arguments

int n_observations   (Input)
Number of blocks for each treatment.

int n_variables   (Input)
Number of treatments.

float *x   (Input)
Array of size n_observations × n_variables containing the matrix of dichoto­mized data. There are n_observations readings of zero or one on each of the n_variables treatments.

Return Value

The p-value, p_value, for the Cochran Q statistic.

Synopsis with Optional Arguments

#include <imsls.h>

float imsls_f_cochran_q_test (int n_observations, int n_variables, float *x,
IMSLS_X_COL_DIM, int x_col_dim,
IMSLS_Q_STATISTIC, float *q,
0)

Optional Arguments

IMSLS_X_COL_DIM, int x_col_dim   (Input)
Number of columns in x.
Default: x_col_dim = n_variables

IMSLS_Q_STATISTIC, float *q   (Output)
Cochran's Q statistic.

Description

Function imsls_f_cochran_q_test 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_variables) 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, 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.

#include <imsls.h>

int main()

{

    float pq;

    float x[54] = {

        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 = imsls_f_cochran_q_test(18, 3, x, 0);

    printf("pq = %9.5f\n", pq);

    return;

}

Output

pq =   0.00024

Warning Errors

IMSLS_ALL_0_OR_1                                   “x” consists of either all ones or all zeros. “q” is set to NaN (not a number). “pq” is set to 1.0.

Fatal Errors

IMSLS_INVALID_X_VALUES                     “x[#][#]” = #. “x” must consist of zeros and ones only.


Visual Numerics, Inc.
Visual Numerics - Developers of IMSL and PV-WAVE
http://www.vni.com/
PHONE: 713.784.3131
FAX:713.781.9260