Analyzes balanced and partially-balanced lattice experiments. In these experiments, a requirement is that the number of treatments be equal to the square of an integer, such as 9, 16, or 25 treatments. Function lattice also analyzes repetitions of lattice experiments.
int n (Input) Number of missing and non-missing experimental observations. imsls_f_lattice verifies that:
int n_locations (Input) Number of locations or repetitions of the lattice experiments. n_locations must be one or greater. If n_locations>1 then the optional arguments IMSLS_LOCATIONS must be included as input to imsls_f_lattice.
int n_reps (Input) Number of replicates per location. Each replicate should consist of t = n_treatments organized into blocks.
int n_blocks (Input) Number of blocks per location. For every location, n_blocks must be equal to n_blocks= r·k, where r = n_reps and
int n_treatments (Input) Number of treatments t = n_treatments must be equal to k2.
int rep[] (Input) An array of length n containing the replicate identifiers for each observation in y. For a balanced-lattice, the number of replicate identifiers must be equal to n_reps= (k+1). For a partially-balanced lattice, the number of replicate identifiers depends upon whether the design is a simple lattice, triple lattice, etc. imsls_f_lattice verifies that the number of unique replicate identifiers is equal to n_reps. If multiple locations or repetitions of the experiment is conducted, i.e., n_locations>1, then the replicate and block numbers contained in rep and block must agree between repetitions.
int block[] (Input) An array of length n containing the block identifiers for each observation in y. imsls_f_lattice verifies that the number of unique block identifiers is equal to n_blocks. If multiple locations or repetitions of the experiment is conducted, i.e., n_locations>1, then block numbers must agree between repetitions. That is, the i‑th block in every location or repetition must contain the same treatments.
int treatment[] (Input) An array of length n containing the treatment identifiers for each observation in y. Each treatment must be assigned values from 1 to n_treatments. imsls_f_lattice verifies that the number of unique treatment identifiers is equal to n_treatments.
float y[] (Input) An array of length n containing the experimental observations and any missing values. Missing values cannot be omitted. They are indicated by placing a NaN (not a number) in y. The NaN value can be set using either the function imsls_f_machine(6) or imsls_d_machine(6), depending upon whether single or double precision is being used, respectively. The location, replicate, block, and treatment number for each observation in y are identified by the corresponding values in the arguments locations, rep, block, and treatment.
Return Value
Address of a pointer to the memory location of a two dimensional, 7 by 6 array containing the ANOVA table. Each row in this array contains values for one of the effects in the ANOVA table. The first value in each row, anova_tablei,0=anova_table[i*6], identifies the source for the effect associated with values in that row. The remaining values in a row contain the ANOVA table values using the following convention:
j
anova_tablei,j = anova_table[i*6+j]
0
Source Identifier (values described below)
1
Degrees of freedom
2
Sum of squares
3
Mean squares
4
F-statistic
5
p-value for this F-statistic
Note that the p‑value for the F-statistic is returned as 0.0 when the value is so small that all significant digits have been lost.
The Source Identifiers in the first column of anova_tablei,j are the only negative values in anova_table[]. Assignments of identifiers to ANOVA sources use the following coding:
Source Identifier
ANOVA Source
-1
LOCATIONS †
-2
REPLICATES
-3
TREATMENTS(unadjusted)
-4
TREATMENTS(adjusted)
-5
BLOCKS(adjusted)
-6
INTRA-BLOCK ERROR
-7
CORRECTED TOTAL
Note: † If n_locations=1, all entries in this row are set to missing (NaN).
Synopsis with Optional Arguments
#include<imsl.h>
float*imsls_f_lattice(intn, intn_locations, int n_reps, intn_blocks, int n_treatments, intrep[], int block[], inttreatment[], float y[],
IMSLS_LOCATIONS, intlocations[](Input) An array of length n containing the location or repetition identifiers for each observation in y. Unique integers must be assigned to each location in the study. This argument is required when n_locations>1.
IMSLS_N_MISSING, int*n_missing(Output) Number of missing values, if any, found in y. Missing values are denoted with a NaN (Not a Number) value.
IMSLS_CV, float*cv(Output) The coefficient of variation computed by using the location standard deviation.
IMSLS_GRAND_MEAN, float*grand_mean (Output) The overall adjusted mean averaged over every location.
IMSLS_TREATMENT_MEANS, float**treatment_means(Output) Address of a pointer to an internally allocated array of size n_treatments containing the adjusted treatment means.
IMSLS_TREATMENT_MEANS_USER, floattreatment_means[] (Output) Storage for the array treatment_means, provided by the user.
IMSLS_STD_ERRORS, float**std_err(Output) Address of a pointer to an internally allocated array of length 4 containing the standard error and associated degrees of freedom for comparing two treatment means. std_err[0] contains the standard error for comparing two treatments that appear in the same block at least once. std_err[1] contains the standard error for comparing two treatments that never appear in the same block together. std_err[2] contains the standard error for comparing, on average, two treatments from the experiment averaged over cases in which the treatments do or do not appear in the same block. Finally, std_err[3] contains the degrees of freedom associated with each of these standard errors, i.e., std_err[3]= degrees of freedom for intra-block error.
IMSLS_STD_ERRORS_USER, floatstd_err[] (Output) Storage for the array std_err, provided by the user.
IMSLS_LOCATION_ANOVA_TABLE, float**location_anova_table (Output) Address of a pointer to an internally allocated 3-dimensional array of size n_locations by 7 by 6 containing the anova tables associated with each location or repetition of the lattice experiment. For each location, the 7 by 6 dimensional array corresponds to the anova table for that location. For example, location_anova_table[(i-1)×42+(j-1)×6 + (k-1)] contains the value in the k‑th column and j‑th row of the anova-table for the i‑th location.
IMSLS_LOCATION_ANOVA_TABLE_USER, floatanova_table[] (Output) Storage for the array location_anova_table, provided by the user.
IMSLS_ANOVA_ROW_LABELS, char***anova_row_labels (Output) Address of a pointer to a pointer to an internally allocated array containing the labels for each of the n_anova rows of the returned ANOVA table. The label for the i‑th row of the ANOVA table can be printed with printf("%s", anova_row_labels[i]); The memory associated with anova_row_labels can be freed with a single call to imsls_free(anova_row_labels).
IMSLS_ANOVA_ROW_LABELS_USER, char*anova_row_labels[] (Output) Storage for the array anova_row_labels, provided by the user. The amount of space required will vary depending upon the number of factors and n_anova. An upperbound on the required memory is char*anova_row_labels[600];
IMSLS_RETURN_USER, floatanova_table[] (Output) User defined array of length 42 for storage of the 7 by 6 anova table described as the return argument for imsls_f_lattice. For a detailed description of the format for this table, see the previous description of the return arguments for imsls_d_lattice.
Description
The function imsls_f_lattice analyzes both balanced and partially-balanced lattice experiments, possibly repeated at multiple locations. These designs were originally described by Yates (1936). A defining characteristic of these classes of lattice experiments is that the number of treatments is always the square of an integer, such as t = 9, 16, 25, etc. where t is equal to the number of treatments.
Another characteristic of lattice experiments is that blocks are organized into replicates, where each replicate contains one observation for each treatment. This requires the number of blocks in each replicate to be equal to the number of observations per block. That is, the number of blocks per replicate and the number of observations per block are both equal to .
For balanced lattice experiments the number of replicates is always . For partially-balanced lattice experiments, the number of replicates is less than . Tables of balanced-lattice experiments are tabulated in Cochran & Cox (1950) for t=9, 16, 25, 49, 64 and 81.
The analysis of balanced and partially-balanced experiments is detailed in Cochran & Cox (1950) and Kuehl (2000).
Consider, for example, a 3x3 balanced-lattice, i.e., k=3 and t=9. Notice that the number of replicates is 4 and the number of blocks per replicate is equal to 3. The total number of blocks is equal to
For a balanced-lattice,
Table 4.19 — A 3x3 Balanced-Lattice for 9 Treatments in Four Replicates
Replicate I
Replicate II
Block 1 (T1, T2, T3)
Block 4 (T1, T4, T7)
Block 2 (T4, T5, T6)
Block 5 (T2, T5, T8)
Block 3 (T7, T8, T9)
Block 6 (T3, T6, T9)
Replicate III
Replicate IV
Block 7 (T1, T5, T9)
Block 10 (T1, T6, T8)
Block 8 (T2, T6, T7)
Block 11 (T2, T4, T9)
Block 9 (T3, T4, T8)
Block 12 (T3, T5, T7)
The analysis of variance for data from a balanced-lattice experiment, takes the form familiar to other balanced incomplete block experiments. In these experiments, the error term is divided into two components: the Inter-Block Error and the Intra-Block Error. For single and multiple locations, the general format of the anova tables is illustrated in the Table 4.20 and Table 4.21.
Table 4.20 — The ANOVA Table for a Lattice Experiment at one Location
SOURCE
DF
Sum of Squares
Mean Squares
REPLICATES
SSR
MSR
TREATMENTS(unadj)
SST
MST
TREATMENTS(adj)
SSTa
MSTa
BLOCKS(adj)
SSBa
MSBa
INTRA-BLOCK ERROR
SSI
MSI
TOTAL
SSTot
Table 4.21 — The ANOVA Table for a Lattice Experiment at Multiple Locations
SOURCE
DF
Sum of Squares
Mean Squares
LOCATIONS
SSL
MSL
REPLICATES WITHIN LOCATIONS
SSR
MSR
TREATMENTS(unadj)
SST
MST
TREATMENTS(adj)
SSTa
MSTa
BLOCKS(adj)
SSB
MSB
INTRA-BLOCK ERROR
SSI
MSI
TOTAL
SSTot
Examples
Example 1
This example is a lattice design for 16 treatments conducted at one location. A lattice design with t=k2=16 treatments is a balanced lattice design with r= k+1=5 replicates and rk=5(4)=20 blocks.
Corrected Total ........... -7 79 60333.88 ....... ....... .......
Adjusted Grand Mean: 171.450
Coefficient of Variation: 10.710
Adjusted Treatment Means:
treatment[ 1] 166.4533
treatment[ 2] 160.7527
treatment[ 3] 183.6289
treatment[ 4] 175.6298
treatment[ 5] 162.6806
treatment[ 6] 167.6717
treatment[ 7] 168.3821
treatment[ 8] 176.5731
treatment[ 9] 162.6928
treatment[10] 118.5197
treatment[11] 189.0615
treatment[12] 190.4607
treatment[13] 169.4514
treatment[14] 197.0827
treatment[15] 185.3560
treatment[16] 168.8029
Standard Error for Comparing Two Adjusted Treatment Means: 13.221801
(df=45)
[group] Mean LSD Grouping
[10] 118.519737
[2] 160.752731 *
[5] 162.680649 * *
[9] 162.692841 * *
[1] 166.453323 * * *
[6] 167.671661 * * *
[7] 168.382111 * * *
[16] 168.802887 * * *
[13] 169.451370 * * *
[4] 175.629776 * * * *
[8] 176.573090 * * * *
[3] 183.628906 * * * *
[15] 185.355988 * * * *
[11] 189.061508 * * *
[12] 190.460724 * *
[14] 197.082703 *
Example 2
This example consists of a 5 × 5 partially-balanced lattice repeated twice. In this case, the number of replicates is not k+1 = 6, it is only n_reps = 2. Each lattice consists of total of 50 observations which is repeated twice. The first observation in this experiment is missing.