NAG FL Interface
g08alf (test_cochranq)
1
Purpose
g08alf performs the Cochran -test on cross-classified binary data.
2
Specification
Fortran Interface
Integer, Intent (In) |
:: |
n, k, ldx |
Integer, Intent (Inout) |
:: |
ifail |
Real (Kind=nag_wp), Intent (In) |
:: |
x(ldx,k) |
Real (Kind=nag_wp), Intent (Out) |
:: |
q, prob |
|
C Header Interface
#include <nag.h>
void |
g08alf_ (const Integer *n, const Integer *k, const double x[], const Integer *ldx, double *q, double *prob, Integer *ifail) |
|
C++ Header Interface
#include <nag.h> extern "C" {
void |
g08alf_ (const Integer &n, const Integer &k, const double x[], const Integer &ldx, double &q, double &prob, Integer &ifail) |
}
|
The routine may be called by the names g08alf or nagf_nonpar_test_cochranq.
3
Description
Cochran's -test may be used to test for differences between treatments applied independently to individuals or blocks ( related samples of equal size ), 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 or 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.
: |
the treatments are equally effective, that is the probability of obtaining a within a block is the same for each treatment. |
: |
there is a difference between the treatments, that is the probability of obtaining a is not the same for different treatments within blocks. |
The data is often represented in the form of a table with the
rows representing the blocks and the
columns the treatments. Let
represent the row totals, for
, and
represent the column totals, for
. Let
represent the response or result where
or
.
|
Treatments |
|
Blocks |
1 |
2 |
|
|
Row Totals |
1 |
|
|
|
|
|
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Column Totals |
|
|
|
|
|
If
, for
and
, then the hypotheses may be restated as follows
: |
, for each . |
: |
, for some and , and for some . |
The test statistic is defined as
When the number of blocks,
, is large relative to the number of treatments,
,
has an approximate
-distribution with
degrees of freedom. This is used to find the probability,
, of obtaining a statistic greater than or equal to the computed value of
. Thus
is the upper tail probability associated with the computed value of
, where the
-distribution is used to approximate the true distribution of
.
4
References
Conover W J (1980) Practical Nonparametric Statistics Wiley
Siegel S (1956) Non-parametric Statistics for the Behavioral Sciences McGraw–Hill
5
Arguments
-
1:
– Integer
Input
-
On entry: , the number of blocks.
Constraint:
.
-
2:
– Integer
Input
-
On entry: , the number of treatments.
Constraint:
.
-
3:
– Real (Kind=nag_wp) array
Input
-
On entry: the matrix of observed zero-one data.
must contain the value , for and .
Constraint:
or , for and .
-
4:
– Integer
Input
-
On entry: the first dimension of the array
x as declared in the (sub)program from which
g08alf is called.
Constraint:
.
-
5:
– Real (Kind=nag_wp)
Output
-
On exit: the value of the Cochran -test statistic.
-
6:
– Real (Kind=nag_wp)
Output
-
On exit: the upper tail probability,
, associated with the Cochran
-test statistic, that is the probability of obtaining a value greater than or equal to the observed value (the output value of
q).
-
7:
– Integer
Input/Output
-
On entry:
ifail must be set to
,
or
to set behaviour on detection of an error; these values have no effect when no error is detected.
A value of causes the printing of an error message and program execution will be halted; otherwise program execution continues. A value of means that an error message is printed while a value of means that it is not.
If halting is not appropriate, the value
or
is recommended. If message printing is undesirable, then the value
is recommended. Otherwise, the value
is recommended.
When the value or is used it is essential to test the value of ifail on exit.
On exit:
unless the routine detects an error or a warning has been flagged (see
Section 6).
6
Error Indicators and Warnings
If on entry
or
, explanatory error messages are output on the current error message unit (as defined by
x04aaf).
Errors or warnings detected by the routine:
-
On entry, .
Constraint: .
On entry, and .
Constraint: .
On entry, .
Constraint: .
-
On entry, , and .
Constraint: or .
-
The solution has failed to converge while calculating the tail probability. The returned result may still be a reasonable approximation.
An unexpected error has been triggered by this routine. Please
contact
NAG.
See
Section 7 in the Introduction to the NAG Library FL Interface for further information.
Your licence key may have expired or may not have been installed correctly.
See
Section 8 in the Introduction to the NAG Library FL Interface for further information.
Dynamic memory allocation failed.
See
Section 9 in the Introduction to the NAG Library FL Interface for further information.
7
Accuracy
The use of the -distribution as an approximation to the true distribution of the Cochran -test statistic improves as increases and as increases relative to . This approximation should be a reasonable one when the total number of observations left, after omitting those rows containing all or , is greater than about and the number of rows left is larger than .
8
Parallelism and Performance
g08alf is not threaded in any implementation.
None.
10
Example
The following example is taken from page 201 of
Conover (1980). The data represents the success of three basketball enthusiasts in predicting the outcome of
collegiate basketball games, selected at random, using
for successful prediction of the outcome and
for unsuccessful prediction. This data is read in and the Cochran
-test statistic and its corresponding upper tail probability are computed and printed.
10.1
Program Text
10.2
Program Data
10.3
Program Results