hide long namesshow long names
hide short namesshow short names
Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

NAG Toolbox: nag_nonpar_test_cochranq (g08al)

Purpose

nag_nonpar_test_cochranq (g08al) performs the Cochran QQ-test on cross-classified binary data.

Syntax

[q, prob, ifail] = g08al(x, 'n', n, 'k', k)
[q, prob, ifail] = nag_nonpar_test_cochranq(x, 'n', n, 'k', k)
Note: the interface to this routine has changed since earlier releases of the toolbox:
Mark 22: n has been made optional
.

Description

Cochran's QQ-test may be used to test for differences between kk treatments applied independently to nn individuals or blocks (kk related samples of equal size nn), where the observed response can take only one of two possible values; for example a treatment may result in a ‘success’ or ‘failure’. The data is recorded as either 11 or 00 to represent this dichotomization.
The use of this ‘randomized block design’ allows the effect of differences between the blocks to be separated from the differences between the treatments. The test assumes that the blocks were randomly selected from all possible blocks and that the result may be one of two possible outcomes common to all treatments within blocks.
The null and alternative hypotheses to be tested may be stated as follows.
H0H0 : the treatments are equally effective, that is the probability of obtaining a 11 within a block is the same for each treatment.
H1H1 : there is a difference between the treatments, that is the probability of obtaining a 11 is not the same for different treatments within blocks.
The data is often represented in the form of a table with the nn rows representing the blocks and the kk columns the treatments. Let RiRi represent the row totals, for i = 1,2,,ni=1,2,,n, and CjCj represent the column totals, for j = 1,2,,kj=1,2,,k. Let xijxij represent the response or result where xij = 0​ or ​1xij=0​ or ​1.
  Treatments  
Blocks 1 2   kk Row Totals
1 x11x11 x12x12 x1kx1k R1R1
2 x21x21 x22x22 x2kx2k R2R2
     
nn xn1xn1 xn2xn2 xnkxnk RnRn
Column Totals C1C1 C2C2   CkCk N = Grand TotalN=Grand Total
If pij = Pr(xij = 1)pij=Pr(xij=1), for i = 1,2,,ni=1,2,,n and j = 1,2,,kj=1,2,,k, then the hypotheses may be restated as follows
H0H0 : pi1 = pi2 = = pikpi1=pi2==pik, for each i = 1,2,,ni=1,2,,n.
H1H1: pijpikpijpik, for some jj and kk, and for some ii.
The test statistic is defined as
Q = (k(k1)j = 1k (CjN/k)2)/(i = 1nRi(kRi)).
Q=k(k-1)j=1k (Cj-Nk) 2 i=1nRi(k-Ri) .
When the number of blocks, nn, is large relative to the number of treatments, kk, QQ has an approximate χ2χ2-distribution with k1k-1 degrees of freedom. This is used to find the probability, pp, of obtaining a statistic greater than or equal to the computed value of QQ. Thus pp is the upper tail probability associated with the computed value of QQ, where the χ2χ2-distribution is used to approximate the true distribution of QQ.

References

Conover W J (1980) Practical Nonparametric Statistics Wiley
Siegel S (1956) Non-parametric Statistics for the Behavioral Sciences McGraw–Hill

Parameters

Compulsory Input Parameters

1:     x(ldx,k) – double array
ldx, the first dimension of the array, must satisfy the constraint ldxnldxn.
The matrix of observed zero-one data. x(i,j)xij must contain the value xijxij, for i = 1,2,,ni=1,2,,n and j = 1,2,,kj=1,2,,k.
Constraint: x(i,j) = 0.0xij=0.0 or 1.01.0, for i = 1,2,,ni=1,2,,n and j = 1,2,,kj=1,2,,k.

Optional Input Parameters

1:     n – int64int32nag_int scalar
Default: The first dimension of the array x.
nn, the number of blocks.
Constraint: n2n2.
2:     k – int64int32nag_int scalar
Default: The second dimension of the array x.
kk, the number of treatments.
Constraint: k2k2.

Input Parameters Omitted from the MATLAB Interface

ldx

Output Parameters

1:     q – double scalar
The value of the Cochran QQ-test statistic.
2:     prob – double scalar
The upper tail probability, pp, associated with the Cochran QQ-test statistic, that is the probability of obtaining a value greater than or equal to the observed value (the output value of q).
3:     ifail – int64int32nag_int scalar
ifail = 0ifail=0 unless the function detects an error (see [Error Indicators and Warnings]).

Error Indicators and Warnings

Errors or warnings detected by the function:

Cases prefixed with W are classified as warnings and do not generate an error of type NAG:error_n. See nag_issue_warnings.

  ifail = 1ifail=1
On entry,n < 2n<2,
ork < 2k<2,
orldx < nldx<n.
  ifail = 2ifail=2
On entry,x(i,j)0.0xij0.0 or 1.01.0 for some ii and jj, i = 1,2,,ni=1,2,,n and j = 1,2,,kj=1,2,,k.
W ifail = 3ifail=3
The approximation process used to calculate the tail probability has failed to converge. The result returned in prob may still be a reasonable approximation.

Accuracy

The use of the χ2χ2-distribution as an approximation to the true distribution of the Cochran QQ-test statistic improves as kk increases and as nn increases relative to kk. This approximation should be a reasonable one when the total number of observations left, after omitting those rows containing all 00 or 11, is greater than about 2525 and the number of rows left is larger than 55.

Further Comments

None.

Example

function nag_nonpar_test_cochranq_example
x = [1, 1, 1;
     1, 1, 1;
     0, 1, 0;
     1, 1, 0;
     0, 0, 0;
     1, 1, 1;
     1, 1, 1;
     1, 1, 0;
     0, 0, 1;
     0, 1, 0;
     1, 1, 1;
     1, 1, 1];
[q, prob, ifail] = nag_nonpar_test_cochranq(x)
 

q =

    2.8000


prob =

    0.2466


ifail =

                    0


function g08al_example
x = [1, 1, 1;
     1, 1, 1;
     0, 1, 0;
     1, 1, 0;
     0, 0, 0;
     1, 1, 1;
     1, 1, 1;
     1, 1, 0;
     0, 0, 1;
     0, 1, 0;
     1, 1, 1;
     1, 1, 1];
[q, prob, ifail] = g08al(x)
 

q =

    2.8000


prob =

    0.2466


ifail =

                    0



PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2013