The routine may be called by the names g04bcf or nagf_anova_rowcol.
In a row and column design the experimental material can be characterised by a two-way classification, nominally called rows and columns. Each experimental unit can be considered as being located in a particular row and column. It is assumed that all rows are of the same length and all columns are of the same length. Sets of equal numbers of rows/columns can be grouped together to form replicates, sometimes known as squares or rectangles, as appropriate.
If for a replicate, the number of rows, the number of columns and the number of treatments are equal and every treatment occurs once in each row and each column then the design is a Latin square. If this is not the case the treatments will be non-orthogonal to rows and columns. For example in the case of a lattice square each treatment occurs only once in each square.
For a row and column design, with treatments in rows and columns and replicates or squares with observations the linear model is:
for , , and , where is the effect of the th replicate, is the effect of the th row, is the effect of the th column and the notation indicates that the th treatment is applied to the unit in row , column of replicate .
To compute the analysis of variance for a row and column design the mean is computed and subtracted from the observations to give, . Since the replicates, rows and columns are orthogonal the estimated effects, ignoring treatment effects, , , , can be computed using the appropriate means of the , and the unadjusted sum of squares computed as the appropriate sum of squared totals for the divided by number of units per total. The observations adjusted for replicates, rows and columns can then be computed by subtracting the estimated effects from to give .
In the case of a Latin square design the treatments are orthogonal to replicates, rows and columns and so the treatment effects, , can be estimated as the treatment means of the adjusted observations, . The treatment sum of squares is computed as the sum of squared treatment totals of the divided by the number of times each treatment is replicated. Finally the residuals, and hence the residual sum of squares, are given by .
For a design which is not orthogonal, for example a lattice square or an incomplete Latin square, the treatment effects adjusted for replicates, rows and columns need to be computed. The adjusted treatment effects are found as the solution to the equations:
where is the vector of the treatment totals of the observations adjusted for replicates, rows and columns, , is a diagonal matrix with equal to the number of times the th treatment is replicated, and is the incidence matrix, with equal to the number of times treatment occurs in replicate , with and being similarly defined for rows and columns. The solution to the equations can be written as:
where, is a generalized inverse of . The solution is found from the eigenvalue decomposition of . The residuals are first calculated by subtracting the estimated adjusted treatment effects from the adjusted observations to give . However, since only the unadjusted replicate, row and column effects have been removed and they are not orthogonal to treatments, the replicate, row and column means of the have to be subtracted to give the correct residuals, and residual sum of squares.
Given the sums of squares, the mean squares are computed as the sums of squares divided by the degrees of freedom. The degrees of freedom for the unadjusted replicates, rows and columns are , and respectively and for the Latin square designs the degrees of freedom for the treatments is . In the general case the degrees of freedom for treatments is the rank of the matrix . The -statistic given by the ratio of the treatment mean square to the residual mean square tests the hypothesis:
The standard errors for the difference in treatment effects, or treatment means, for Latin square designs, are given by:
where is the residual mean square. In the general case the variances of the treatment effects are given by:
from which the appropriate standard errors of the difference between treatment effects or the difference between adjusted means can be calculated.
The analysis of a row-column design can be considered as consisting of different strata: the replicate stratum, the rows within replicate and the columns within replicate strata and the units stratum. In the Latin square design all the information on the treatment effects is given at the units stratum. In other designs there may be a loss of information due to the non-orthogonality of treatments and replicates, rows and columns and information on treatments may be available in higher strata. The efficiency of the estimation at the units stratum is given by the (canonical) efficiency factors, these are the nonzero eigenvalues of the matrix, , divided by the number of replicates in the case of equal replication, or by the mean of the number of replicates in the unequally replicated case, see John (1987). If more than one eigenvalue is zero then the design is said to be disconnected and information on some treatment comparisons can only be obtained from higher strata.
Cochran W G and Cox G M (1957) Experimental Designs Wiley
Davis O L (1978) The Design and Analysis of Industrial Experiments Longman
John J A (1987) Cyclic Designs Chapman and Hall
John J A and Quenouille M H (1977) Experiments: Design and Analysis Griffin
Searle S R (1971) Linear Models Wiley
1: – IntegerInput
On entry: , the number of replicates.
2: – IntegerInput
On entry: , the number of rows per replicate.
3: – IntegerInput
On entry: , the number of columns per replicate.
4: – Real (Kind=nag_wp) arrayInput
On entry: the observations ordered by columns within rows within replicates. That is
contains the observation from the th column of the th row of the th replicate, for , and .
5: – IntegerInput
On entry: the number of treatments. If only replicates, rows and columns are required in the analysis then set .
6: – Integer arrayInput
Note: the dimension of the array it
must be at least
if , and at least otherwise.
On entry: if ,
indicates which of the nt treatments unit received, for .
On exit: if ,
contains the (adjusted) mean for the th treatment, , for , where is the mean of the treatment adjusted observations . Otherwise tmean is not referenced.
9: – Real (Kind=nag_wp) arrayOutput
On exit: the analysis of variance table. Column 1 contains the degrees of freedom, column 2 the sum of squares, and where appropriate, column 3 the mean squares, column 4 the -statistic and column 5 the significance level of the -statistic. Row 1 is for replicates, row 2 for rows, row 3 for columns, row 4 for treatments (if ), row 5 for residual and row 6 for total. Mean squares are computed for all but the total row, -statistics and significance are computed for treatments, replicates, rows and columns. Any unfilled cells are set to zero.
10: – IntegerInput
On entry: the first dimension of the array tabl as declared in the (sub)program from which g04bcf is called.
11: – Real (Kind=nag_wp) arrayOutput
On exit: the upper triangular part of c contains the variance-covariance matrix of the treatment effects, the strictly lower triangular part contains the standard errors of the difference between two treatment effects (means),
i.e., contains the covariance of treatment and if and the standard error of the difference between treatment and if , for and .
12: – IntegerInput
On entry: the first dimension of the array c as declared in the (sub)program from which g04bcf is called.
13: – Integer arrayOutput
On exit: if , the treatment replications,
, for . Otherwise irep is not referenced.
14: – Real (Kind=nag_wp) arrayOutput
On exit: if ,
contains the mean for the th replicate, , for . Otherwise rpmean is not referenced.
15: – Real (Kind=nag_wp) arrayOutput
On exit: contains the mean for the th row, , for .
16: – Real (Kind=nag_wp) arrayOutput
On exit: contains the mean for the th column, , for .
17: – Real (Kind=nag_wp) arrayOutput
On exit: the residuals,
, for .
18: – Real (Kind=nag_wp) arrayOutput
On exit: if , the canonical efficiency factors. Otherwise ef is not referenced.
19: – Real (Kind=nag_wp)Input
On entry: the tolerance value used to check for zero eigenvalues of the matrix . If a default value of is used.
20: – IntegerInput
On entry: an adjustment to the degrees of freedom for the residual and total.
The degrees of freedom for the total is set to and the residual degrees of freedom adjusted accordingly.
The total degrees of freedom for the total is set to , as usual.
21: – Real (Kind=nag_wp) arrayWorkspace
22: – IntegerInput/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 since useful values can be provided in some output arguments even when on exit. 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).
6Error 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:
Note: in some cases g04bcf may return useful information.
On entry, .
On entry, and .
On entry, .
On entry, .
On entry, .
On entry, .
On entry, .
On entry, .
On entry, at least one treatment is not present. Treatment does not appear in it.
A computed standard error is zero. This is due to rounding errors and is an unlikely error exit.
The computation of the eigenvalues has failed to converge. This is an unlikely error exit.
The treatments are totally confounded with blocks. The treatment sum of squares and degrees of freedom are zero. The analysis of variance table is not computed, except for block and total sums of squares and degrees of freedom.
The residual degrees of freedom is zero. Columns and of the analysis of variance table will not be computed and the matrix of standard errors and covariances, c, will not be scaled by or .
The residual mean square is zero. Columns and of the analysis of variance table will not be computed and the matrix of standard errors and covariances, c, will not be scaled by or .
The design is disconnected. The standard errors may not valid. The design may be nested.
An unexpected error has been triggered by this routine. Please
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.
The algorithm used in g04bcf, described in Section 3, achieves greater accuracy than the traditional algorithms based on the subtraction of sums of squares.
8Parallelism and Performance
Background information to multithreading can be found in the Multithreading documentation.
g04bcf is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
g04bcf makes calls to BLAS and/or LAPACK routines, which may be threaded within the vendor library used by this implementation. Consult the documentation for the vendor library for further information.
Please consult the X06 Chapter Introduction for information on how to control and interrogate the OpenMP environment used within this routine. Please also consult the Users' Note for your implementation for any additional implementation-specific information.
To estimate missing values the Healy and Westmacott procedure or its derivatives may be used, see John and Quenouille (1977). This is an iterative procedure in which estimates of the missing values are adjusted by subtracting the corresponding values of the residuals. The new estimates are then used in the analysis of variance. This process is repeated until convergence. A suitable initial value may be the grand mean. When using this procedure irdf should be set to the number of missing values plus one to obtain the correct degrees of freedom for the residual sum of squares.
For analysis of covariance the residuals are obtained from an analysis of variance of both the response variable and the covariates. The residuals from the response variable are then regressed on the residuals from the covariates using, say, g02cbforg02daf. The results from those routines can be used to test for the significance of the covariates. To test the significance of the treatment effects after fitting the covariate, the residual sum of squares from the regression should be compared with the residual sum of squares obtained from the equivalent regression but using the residuals from fitting replicates, rows and columns only.
The data for a Latin square is input and the ANOVA and treatment means computed and printed. Since the design is orthogonal only one standard error need be printed