Generates mutually orthogonal Latin squares (I. Wakeling & R.W. Payne).

### Options

`PRINT` = string token |
Controls printed output (`design` , `squares` , `list` ); if unset in an interactive run `AGLATIN` will ask whether the design is to be printed, in a batch run the default is not to print anything |
---|---|

`ANALYSE` = string token |
Controls whether or not to analyse the design, and produce a skeleton analysis-of-variance table using `ANOVA` (`no` , `yes` ); default is to ask if this is unset in an interactive run, and not to analyse if it is unset in a batch run |

### Parameters

`NROWS` = scalars |
Specifies the number of rows (and columns) in each square |
---|---|

`NSQUARES` = scalars |
Number of squares to form (i.e. number of treatment factors to generate) |

`SEED` = scalars |
Seed to be used to randomize each design; a negative value implies no randomization |

`TREATMENTFACTORS` = pointers |
Pointer to identifiers for the treatment factors |

`ROWS` = factors |
Identifier for the row factor |

`COLUMNS` = factors |
Identifier for the column factor |

`MAXNSQUARES` = scalars |
Returns the maximum number of squares available with the specified number of rows and columns |

`STATEMENT` = texts |
Saves a command to recreate each design (useful if the design information has been specified in response to questions from `AGLATIN` ) |

### Description

`AGLATIN`

generates a set of orthogonal Latin squares, or a single square. It is easiest to use interactively. All the information required to generate the squares is then obtained by (clearly explained) questions. You need set the parameters only if you wish to anticipate some of the questions, or if you wish to use `AGLATIN`

in batch. If, however, you wish to recreate the same design later, the `STATEMENT`

parameter allows you to save a Genstat text structure containing a command specifying the same information.

The size of the squares (i.e. the number of rows and columns) can be specified by the `NROWS`

option, and the number of squares (i.e. the number of treatment factors to be generated) can be specified by the `NSQUARES`

option. The `MAXNSQUARES`

parameter can be used to ascertain how many squares are available. If this is set but `NSQUARES`

is not set, the procedure then stops. Otherwise, when `AGLATIN`

is being used interactively, if `NSQUARES`

is unset you will be asked how many squares you want.

The squares are represented as a row factor, a column factor and `NSQUARES`

treatment factors all of length `NROWS**2`

. The `ROWS`

and `COLUMNS`

parameters can supply identifiers for the row and column factors, so that they are accessible outside the procedure. The `TREATMENTFACTORS`

parameter can specify a pointer to supply identifiers for the treatment factors. For example, if there are two factors you could define their identifiers to be `A`

and `B`

by forming the pointer `Tf`

(say) with the statement

`POINTER [VALUES=A,B] Tf`

and then setting `TREATMENTFACTORS=Tf`

. Alternatively, and more succinctly, you could put `TREATMENTFACTORS=!p(A,B)`

, where `!p(A,B)`

is an unnamed pointer containing the required two identifiers.

The `SEED`

parameter allows you to specify a seed to randomize the design. In a batch run, this has a default of -1, to suppress randomization. If `SEED`

is unset in an interactive run, you will be asked to provide a seed (and again a negative value will leave the design unrandomized).

The `PRINT`

option controls whether `AGLATIN`

prints the design. The setting `design`

prints it as a square table of treatment factors tabulated by the row and column factors, `squares`

prints each treatment factor separately (again tabulated by rows and columns), and `list`

prints row, column and treatment factor values as a list. By default, if you are running Genstat in batch, the nothing is printed. If you do not set `PRINT`

when running interactively, `AGLATIN`

will ask what you want to print. Similarly the `ANALYSE`

option governs whether or not `AGLATIN`

produces a skeleton analysis-of-variance table (containing just source of variation, degrees of freedom and efficiency factors). Again `AGLATIN`

assumes that this is not required if `ANALYSE`

is unset in a batch run, and asks whether it is required if `ANALYSE`

is unset in an interactive run.

Options: `PRINT`

, `ANALYSE`

.

Parameters: `NROWS`

, `NSQUARES`

, `SEED`

, `TREATMENTFACTORS`

, `ROWS`

, `COLUMNS`

, `MAXNSQUARES`

, `STATEMENT`

.

### Method

If the order of squares required is prime or any integer power of a prime number, the approach is to call `GALOIS`

to obtain the multiplication table for the field GF[`NROWS`

] and then cyclically develop the columns from the multiplication table to give the squares.

If the parameter `NROWS`

is a composite number and, when decomposed into prime powers has a smallest prime power (*f* = *p ^{n}*) greater than or equal to 3, then it is possible to construct

*f*-1 orthogonal squares using the MacNeish-Mann method (Raghavarao 1971, p. 34). In the event that the smallest prime power is 2, it is possible to generate a single Latin square using the same approach. Essentially this process consists of embedding Galois fields one inside another. For each distinct prime factor the multiplication and addition tables from the corresponding fields are obtained by calling the procedure

`GALOIS`

. Note that while this method is general, it does not guarantee to find the maximum possible number of mutually orthogonal squares of any given order. For example, the following list details the number of squares generated for orders up to and including 40.Order Number of squares generated

12 2

15 2

20 3

21 2

24 2

28 3

33 2

35 4

39 2

40 4

For the orders 10, 14, 18 and 22, the procedure uses self-orthogonal squares (Franklin 1984) to give pairs of orthogonal Latin squares. The first rows of a square one order less than required are defined inside the procedure, these are developed by replacement of one of the broken diagonals with a new symbol and the addition of another row and column to produce a bordered cyclic Latin square. The second square in the pair is simply the transpose of the first.

### References

Franklin, M.F. (1984). Cyclic generation of self-orthogonal Latin squares. *Utilitas Mathematica*, 25, 135-146.

MacNeish, H.F. (1922). Euler’s squares. *Annals of Mathematics*, 23, 221-227

Mann, H.B. (1942). The construction of orthogonal Latin squares. *Annals of Mathematical Statistics*, 13, 418-423.

Raghavarao, D. (1971). *Constructions and Combinatorial Problems in Design of Experiments*. John Wiley, New York.

### See also

Procedures: `AGCROSSOVERLATIN`

, `AGSEMILATIN`

, `AGQLATIN`

, `AGYOUDENSQUARE`

, `GALOIS`

.

Commands for: Design of experiments, Analysis of variance.

### Example

CAPTION 'AGLATIN example','This generates a Graeco-Latin square of size 12.';\ STYLE=meta,plain AGLATIN [PRINT=design; ANALYSE=yes] 12; NSQUARES=2;\ TREATMENTFACTORS=!p(Latin,Graeco); ROWS=Rows; COLUMNS=Columns;\ SEED=-1