G04AGF performs an analysis of variance for a two-way hierarchical classification with subgroups of possibly unequal size, and also computes the treatment group and subgroup means. A fixed effects model is assumed.
SUBROUTINE G04AGF ( |
Y, N, K, LSUB, NOBS, L, NGP, GBAR, SGBAR, GM, SS, IDF, F, FP, IFAIL) |
INTEGER |
N, K, LSUB(K), NOBS(L), L, NGP(K), IDF(4), IFAIL |
REAL (KIND=nag_wp) |
Y(N), GBAR(K), SGBAR(L), GM, SS(4), F(2), FP(2) |
|
In a two-way hierarchical classification, there are
(
) treatment groups, the
th of which is subdivided into
treatment subgroups. The
th subgroup of group
contains
observations, which may be denoted by
The general observation is denoted by
, being the
th observation in subgroup
of group
, for
,
,
.
The following quantities are computed
(i) |
The subgroup means
|
(ii) |
The group means
|
(iii) |
The grand mean
|
(iv) |
The number of observations in each group
|
(v) |
Sums of squares
|
(vi) |
Degrees of freedom of variance components
Between groups: |
|
Subgroups within groups: |
|
Residual: |
|
Total: |
|
where
|
(vii) |
ratios. These are the ratios of the group and subgroup mean squares to the residual mean square.
Groups |
|
Subgroups |
|
If either ratio exceeds , the value is assigned instead. |
(viii) |
F significances. The probability of obtaining a value from the appropriate -distribution which exceeds the computed mean square ratio.
Groups |
|
Subgroups |
|
where denotes the central -distribution with degrees of freedom and .
If any , then is set to zero, . |
- 1: Y(N) – REAL (KIND=nag_wp) arrayInput
On entry: the elements of
Y must contain the observations
in the following order:
In words, the ordering is by group, and within each group is by subgroup, the members of each subgroup being in consecutive locations in
Y.
- 2: N – INTEGERInput
On entry: , the total number of observations.
- 3: K – INTEGERInput
On entry: , the number of groups.
Constraint:
.
- 4: LSUB(K) – INTEGER arrayInput
On entry: the number of subgroups within group
, , for .
Constraint:
, for .
- 5: NOBS(L) – INTEGER arrayInput
On entry: the numbers of observations in each subgroup,
, in the following order:
Constraint:
, that is and , for .
- 6: L – INTEGERInput
On entry: , the total number of subgroups.
Constraint:
.
- 7: NGP(K) – INTEGER arrayOutput
On exit: the total number of observations in group
, , for .
- 8: GBAR(K) – REAL (KIND=nag_wp) arrayOutput
On exit: the mean for group
, , for .
- 9: SGBAR(L) – REAL (KIND=nag_wp) arrayOutput
On exit: the subgroup means,
, in the following order:
- 10: GM – REAL (KIND=nag_wp)Output
On exit: the grand mean, .
- 11: SS() – REAL (KIND=nag_wp) arrayOutput
On exit: contains the sums of squares for the analysis of variance, as follows;
- Between group sum of squares, ,
- Between subgroup within groups sum of squares, ,
- Residual sum of squares, ,
- Corrected total sum of squares, .
- 12: IDF() – INTEGER arrayOutput
On exit: contains the degrees of freedom attributable to each sum of squares in the analysis of variance, as follows:
- Degrees of freedom for between group sum of squares,
- Degrees of freedom for between subgroup within groups sum of squares,
- Degrees of freedom for residual sum of squares,
- Degrees of freedom for corrected total sum of squares.
- 13: F() – REAL (KIND=nag_wp) arrayOutput
On exit: contains the mean square ratios, and , for the between groups variation, and the between subgroups within groups variation, with respect to the residual, respectively.
- 14: FP() – REAL (KIND=nag_wp) arrayOutput
On exit: contains the significances of the mean square ratios, and respectively.
- 15: IFAIL – INTEGERInput/Output
-
On entry:
IFAIL must be set to
,
. If you are unfamiliar with this parameter you should refer to
Section 3.3 in the Essential Introduction for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value
is recommended. If the output of error messages is undesirable, then the value
is recommended. Otherwise, if you are not familiar with this parameter, the recommended value is
.
When the value 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).
If on entry
or
, explanatory error messages are output on the current error message unit (as defined by
X04AAF).
The computations are believed to be stable.
The time taken by G04AGF increases approximately linearly with the total number of observations, .
This example has two groups, the first of which consists of five subgroups, and the second of three subgroups. The numbers of observations in each subgroup are not equal. The data represent the percentage stretch in the length of samples of sack kraft drawn from consignments (subgroups) received over two years (groups). For details see
Moore et al. (1972).