 
 x = MACHINE(/Float)
y(i) = x.NaN
| J | anova_tablei,j = anova_table(i,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 | 
| Source Identifier | ANOVA Source | 
| –1 | LOCATIONS*  | 
| –2 | ROWS  | 
| –3 | COLUMNS  | 
| –4 | TREATMENTS | 
| –5 | LOCATIONS × TREATMENTS*  | 
| –6 | ERROR WITHIN LOCATIONS | 
| –7 | CORRECTED TOTAL | 
| * If n_locations = 1 rows involving location are set to missing (NaN). | |
| Columns | |||||
| C1 | C2 | C3 | C4 | ||
| Rows | R1 | T1 | T2 | T3 | T4 | 
| R2 | T2 | T3 | T4 | T1 | |
| R3 | T3 | T4 | T1 | T2 | |
| R4 | T4 | T1 | T2 | T3 | |
| SOURCE | DF | Sum of Squares | Mean Squares | 
| ROWS | t – 1 |   | MSR | 
| COLUMNS | t – 1 |   | MSC | 
| TREATMENTS | t – 1 |   | MST | 
| ERROR | (t – 1)(t – 2) | SSE=SSTot-SSR-SSC-SST | MSE | 
| TOTAL | t2 – 1 |   | |
 
  yij(k) is the observation for the kth treatment in the ith row and jth column of the Latin Square.
yij(k) is the observation for the kth treatment in the ith row and jth column of the Latin Square. τk(ij) is the effect associated with the kth treatment.
τk(ij) is the effect associated with the kth treatment. ρi and γj are the ith row and jth column effects, respectively.
ρi and γj are the ith row and jth column effects, respectively. εij(k) is the noise associated with this observation.
εij(k) is the noise associated with this observation. 
  τk(ij) is the effect associated with the kth treatment
τk(ij) is the effect associated with the kth treatment ατlk(ij) is the interaction effect between location l and treatment k.
ατlk(ij) is the interaction effect between location l and treatment k.| SOURCE | DF | Sum of Squares | Mean Squares | 
| LOCATIONS | r – 1 |   | MSL | 
| ROWS | r (t – 1) |   | MSR | 
| COLUMNS | r (t – 1) |   | MSC | 
| TREATMENTS | t – 1 |   | MST | 
| LOCATIONS X TREATMENTS | (r – 1)(t – 1) | SSLT by difference | MSLT | 
| ERROR | (t – 1)(r(t – 1) – 1) |   | MSE | 
| TOTAL |   |   | 
; Total number of observations
n = 16
; Number of locations
n_locations = 1
; Number of rows, columns and treatments
n_treatments = 4
col = [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4]
row = [3, 2, 4, 1, 1, 4, 2, 3, 2, 3, 1, 4, 4, 1, 3, 2]
treatment = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4]
y = [1.167, 1.185, 1.655, 1.345, 1.64 , 1.29, 1.665, 1.29, $
1.475, 0.71, 1.425, 0.66, 1.565, 1.29, 1.4 , 1.18]
aov = LATIN_SQUARE(n, n_locations, n_treatments, row, col, $
treatment, y, cv=cv, $
treatment_means=treatment_means, $
std_err=std_err, $
grand_mean=grand_mean, $
anova_row_labels=anova_row_labels)
PRINT, "*** Experimental Design ***"
PRINT, "========================"
PRINT, "|COL | 1 | 2 | 3 | 4 |"
PRINT, "========================"
PRINT, "|ROW 1 | 2 | 4 | 3 | 1 |"
PRINT, "========================"
PRINT, "|ROW 2 | 3 | 1 | 2 | 4 |"
PRINT, "========================"
PRINT, "|ROW 3 | 1 | 3 | 4 | 2 |"
PRINT, "========================"
PRINT, "|ROW 4 | 4 | 2 | 1 | 3 |"
PRINT, "========================"
PRINT, ''
; Print Analysis of Variance Table
PRINT, " *** ANALYSIS OF VARIANCE TABLE ***"
PRINT, 'ID', 'DF', 'SSQ', 'MS', 'F-test', 'P-Value', $
Format='(A27, A5, A7, A6, A8, A8)' & $
FOR i=0L, (SIZE(aov))(1)-1 DO $
PRINT, anova_row_labels(i), aov(i,0), aov(i,1), $
aov(i,2), aov(i,3), aov(i,4), aov(i,5), Format= $
'(A23, 1X, I3, 2X, F3.0, 1X, F6.2, 1X, F6.2, 2X, ' + $
'F5.2, 2X, F6.3)'
PRINT, ''
PRINT, grand_mean, $
   Format='("Grand Mean              :", F7.3)'PRINT, cv, Format='("Coefficient of Variation:", F7.3)'PRINT, ''
PRINT, "Treatment Means:"
FOR i=0L, n_treatments-1 DO $
PRINT, (i+1), treatment_means(i), Format= $
"(2X, 'Treatment[', I1, '] Mean:', F7.4)"
PRINT, ''
PRINT, std_err(0), Format='("Standard Error for ' + $'Comparing Two Treatment Means: ", F8.6, I1)'
PRINT, FIX(std_err(1)), Format='("(df=", I1, ")")'PRINT, ''
; Perform multiple comparison using the LSD procedure
equal_means = MULTICOMP(treatment_means, std_err(1), $
std_err(0)/SQRT(2.0), $
/LSD, Alpha=0.05)
PM, equal_means, $
Title="LSD Comparison: Size of Groups of Means"
*** Experimental Design ***
========================
|COL | 1 | 2 | 3 | 4 |
========================
|ROW 1 | 2 | 4 | 3 | 1 |
========================
|ROW 2 | 3 | 1 | 2 | 4 |
========================
|ROW 3 | 1 | 3 | 4 | 2 |
========================
|ROW 4 | 4 | 2 | 1 | 3 |
========================
*** ANALYSIS OF VARIANCE TABLE ***
ID DF SSQ MS F-test P-Value
Locations ............. -1 NaN NaN NaN NaN NaN
Rows within Locations . -2 3. 0.18 0.06 2.06 0.207
Columns within Location -3 3. 0.59 0.20 6.58 0.025
Treatments ............ -4 3. 0.35 0.12 3.93 0.073
Locations x Treatments -5 NaN NaN NaN NaN NaN
Error within Locations -6 6. 0.18 0.03 NaN NaN
Corrected Total ....... -7 15. 1.31 NaN NaN NaN
Grand Mean : 1.309
Coefficient of Variation: 13.204
Treatment Means:
Treatment[1] Mean: 1.3380
Treatment[2] Mean: 1.4712
Treatment[3] Mean: 1.0675
Treatment[4] Mean: 1.3587
Standard Error for Comparing Two Treatment Means: 0.122202
(df=6)
LSD Comparison: Size of Groups of Means
3
3
0