Performs analysis of variance of a balanced or unbalanced design with up to two treatment factors (R.W. Payne).

### Options

`PRINT` = string tokens |
Controls printed output from the analysis (`aovtable` , `information` , `covariates` , `effects` , `residuals` , `means` , `%cv` , `missingvalues` ); default `aovt` , `mean` |
---|---|

`TREATMENTS` = factors |
Defines either one or two treatment factors |

`BLOCKS` = factor |
Can specify a blocking factor e.g. for a randomized block design |

`COVARIATES` = variates |
Specifies any covariates |

`FACTORIAL` = scalar |
Can be set to 1 to fit only the main effects of the treatments factors; default 2 also fits their interaction |

`FPROBABILITY` = string token |
Probabilities for variance ratio (`yes` , `no` ); default `no` |

`PLOT` = string tokens |
Which residual plots to provide (`fittedvalues` , `normal` , `halfnormal` , `histogram` , `absresidual` ); default `fitt` , `norm` , `half` , `hist` |

`GRAPHICS` = string token |
Type of graphs (`lineprinter` , `highresolution` ); default `high` |

`COMBINATIONS` = string token |
Factor combinations for which to form predicted means (`present` , `estimable` ); default `esti` |

`ADJUSTMENT` = string token |
Type of adjustment to be made when predicting means (`marginal` , `equal` , `observed` ); default `marg` |

`PSE` = string tokens |
Types of standard errors to be printed with the means (`differences` , `lsd` , `means` , `alldifferences` , `alllsd` ); default `diff` |

`LSDLEVEL` = scalar |
Significance level (%) for least significant differences; default 5 |

`RMETHOD` = string token |
Type of residuals to save or display (`simple` , `standardized` ); default `simp` |

`MVINCLUDE` = string token |
Whether to include units with missing y-values when using `ANOVA` (`yvariate` ); default `*` i.e. not included |

`EXIT` = scalar |
Saves an exit code indicating the properties of the design |

### Parameters

`Y` = variates |
Each of these contains the data values for an analysis |
---|---|

`RESIDUALS` = variates |
Saves the residuals from each analysis |

`FITTEDVALUES` = variates |
Saves the fitted values from each analysis |

`SAVE` = pointers |
Save structure for each analysis (to use in `A2DISPLAY` or `A2KEEP` ) |

### Description

`A2WAY`

provides specialized facilities for analysis of variance with either one or two treatment factors. There can also be a blocking factor. It automatically determines the type of design and uses the appropriate method: the `ANOVA`

directive if the design is balanced, or the regression directives (`FIT`

, `ADD`

and so on) if it is unbalanced. So, for example, it can analyse randomized complete block designs with one or two treatment factors, or unbalanced two-way treatment structures with or without blocking, or designs with a single treatment factor whose levels are allocated unevenly across the blocks. By default, any units with missing values in the y-variate are excluded from the analysis. Conversely, in `ANOVA`

they need to be included to ensure balance in the more general situations that it covers, and are estimated as part of the analysis. However, you can reproduce the `ANOVA`

analysis by setting option `MVINCLUDE=yvariate`

.

The output is also customized. For example, if the treatments have unequal replication, a standard error is printed for each mean, rather than the summary for comparisons of means with minimum and maximum replication as given by `ANOVA`

. Similarly, the two-way analyses show the sums of squares for the main effects both omitting and ignoring the other main effect. In addition, `A2WAY`

provides residual plots directly, instead of requiring you to use procedure `APLOT`

after the analysis.

The `Y`

parameter supplies a variate containing the data values to be analysed. The `RESIDUALS`

parameter can save the residuals from the analysis, and the `FITTEDVALUES`

parameter can save the fitted values. The `RMETHOD`

option controls whether simple or standardized residuals are saved or displayed; by default `RMETHOD=simple`

.

The `SAVE`

parameter can save a “save” structure that can be used as input to procedure `A2DISPLAY`

to produce further output, or to procedure `A2KEEP`

to copy output into Genstat data structures.

The treatment factor or factors are specified by the `TREATMENTS`

option, and the `BLOCKS`

option can be used to supply a blocking factor. Covariates can be supplied using the `COVARIATES`

option. As in `ANOVA`

, the `FACTORIAL`

option sets a limit in the number of factors in each treatment term. So you can set `FACTORIAL=1`

to fit only the main effects when there are two treatment factors; the default `FACTORIAL=2`

also fits their interaction.

Printed output is controlled by the `PRINT`

option, with settings:

`aovtable` |
analysis-of-variance table (probabilities are given for the variance ratios if option `FPROBABILITY=yes` ); |
---|---|

`information` |
information about the design (non-orthogonality &c); |

`covariates` |
covariate regression coefficients); |

`effects` |
treatment parameters in the linear model; |

`means` |
table of means; |

`%cv` |
to print the coefficient of variation; |

`missingvalues` |
to print estimates for any missing values. |

The `PSE`

option controls the types of standard errors that are produced to accompany the tables of means, with settings:

`differences` |
summary of standard errors for differences between pairs of means; |
---|---|

`alldifferences` |
standard errors for differences between all pairs of means (unbalanced designs only); |

`lsd` |
summary of least significant differences between pairs of means; |

`alllsd` |
least significant differences between all pairs of means (unbalanced designs only); |

`means` |
standard errors of the means – for unbalanced designs, these are approximate effective standard errors formed by procedure `SED2ESE` with the aim of allowing good approximations to the standard errors for differences to be calculated by the usual formula of sed = √(ese_{ij}_{i}^{2} + ese_{j}^{2}) |

The default is `differences`

. The `LSDLEVEL`

option sets the significance level

(as a percentage) for the least significant differences.

For unbalanced designs, analysed using Genstat regression, the means are produced using the `PREDICT`

directive. The first step (A) of the calculation forms the full table of predictions, classified by all the treatment and blocking factors. The second step (B) averages the full table over the factors that do not occur in the table of means. The `COMBINATIONS`

option specifies which cells of the full table are to be formed in Step A. The default setting, `estimable`

, fills in all the cells other than those that involve parameters that cannot be estimated. Alternatively, setting `COMBINATIONS=present`

excludes the cells for factor combinations that do not occur in the data. The `ADJUSTMENT`

option then defines how the averaging is done in Step B. The default setting, `marginal`

, forms a table of marginal weights for each factor, containing the proportion of observations with each of its levels; the full table of weights is then formed from the product of the marginal tables. The setting `equal`

weights all the combinations equally. Finally, the setting `observed`

uses the `WEIGHTS`

option of `PREDICT`

to weight each factor combination according to its own individual replication in the data.

The `PLOT`

option allows up to four of the following residual plots to be requested:

`fittedvalues` |
for a plot of residuals against fitted values; |
---|---|

`normal` |
for a Normal plot; |

`halfnormal` |
for a half-Normal plot; |

`histogram` |
for a histogram of residuals; and |

`absresidual` |
for a plot of the absolute values of the residuals against the fitted values. |

By default the first four are produced. The `GRAPHICS`

option determines the type of graphics that is used, with settings `highresolution`

(the default) and `lineprinter`

.

The `RMETHOD`

option controls whether simple or standardized residuals are printed or plotted; by default `RMETHOD=simple`

.

The `EXIT`

option can save an exit code indicating how the analysis was done. For the exact meanings of the values see the `ANOVA`

directive. Essentially, it has the values 0 or 1 if the analysis has been done using `ANOVA`

(0 if design orthogonal and 1 if it is balanced). Other values indicate that it has been done using the regression directives.

Options: `PRINT`

, `TREATMENTS`

, `BLOCKS`

, `COVARIATES`

, `FACTORIAL`

, `FPROBABILITY`

, `PLOT`

, `GRAPHICS`

, `COMBINATIONS`

, `ADJUSTMENT`

, `PSE`

, `LSDLEVEL`

, `RMETHOD`

, `MVINCLUDE`

, `EXIT`

.

Parameters: `Y`

, `RESIDUALS`

, `FITTEDVALUES`

, `SAVE`

.

### Method

The `EXIT`

option of the `ANOVA`

directive is used to determine whether or not the design is unbalanced (and thus whether the Genstat regression facilities need to be used rather than the analysis of variance facilities).

### Action with `RESTRICT`

If the `Y`

variate is restricted, only the units not excluded by the restriction will be analysed.

### See also

Procedures: `A2DISPLAY`

, `A2KEEP`

, `A2RESULTSUMMARY`

Commands for: Analysis of variance.

### Example

CAPTION 'A2WAY example',\ !t('Data from Snedecor & Cochran (1980), Statistical Methods',\ '(7th edition), page 216 and also see page 252.');\ STYLE=meta,plain FACTOR [LEVELS=4; VALUES=(1...4)6] Fat VARIATE [VALUES=64,78,75,55, 72,91,93,66, 68,97,78,49,\ 77,82,71,64, 56,85,63,70, 95,77,76,68] Absorbed A2WAY [PRINT=aov,means; TREATMENTS=Fat; FPROBABILITY=yes] Absorbed CAPTION !t('Experiment on foster feeding of rats from Scheffe (1959)',\ 'The Analysis of Variance; also see McConway, Jones & Taylor (1999)',\ 'Statistical Modelling using GENSTAT, Example 7.6.') FACTOR [NVALUES=61; LABELS=!t('A','B','I','J')] litter READ litter; FREPRESENTATION=labels A A A A A A A A A A A A A A A A A B B B B B B B B B B B B B B B I I I I I I I I I I I I I I J J J J J J J J J J J J J J J : FACTOR [NVALUES=61; LABELS=!t('A','B','I','J')] mother READ mother; FREPRESENTATION=labels A A A A A B B B I I I I J J J J J A A A A B B B B B I I I I J J A A A B B B I I I I I J J J A A A A B B B I I I J J J J J : VARIATE [NVALUES=61] littwt READ littwt 61.5 68.2 64 65 59.7 55 42 60.2 52.5 61.8 49.5 52.7 42 54 61 48.2 39.6 60.3 51.7 49.3 48 50.8 64.7 61.7 64 62 56.5 59 47.2 53 51.3 40.5 37 36.3 68 56.3 69.8 67 39.7 46 61.3 55.3 55.7 50 43.8 54.5 59 57.4 54 47 59.5 52.8 56 45.2 57 61.4 44.8 51.5 53 42 54 : A2WAY [PRINT=aovtable,means,%cv; TREATMENTS=litter,mother;\ PSE=differences,lsd,means,alldifferences,alllsd] littwt