Latin Square Design in R: ANOVA with Row and Column Blocks

See Video ⮞ ☝


Introduction

A Latin square design blocks two sources of spatial variation while comparing treatments. Each treatment appears once in every row and once in every column, so the design is useful when two gradients are known and can be controlled by crossed blocking factors.

Conditions

A Latin square is appropriate when the numbers of treatments, rows, and columns are equal and the experimental units can be arranged into a square layout with one observation per cell.

  • Field trials where fertility gradient exists in two directions perpendicular to each other, or has a unidirectional fertility gradient but also has residual effects from previous trials.
  • Insecticide field trials where the insect migration has a predictable direction that is perpendicular to the dominant fertility gradient of the experimental field.
  • Greenhouse trials in which the experimental pots are arranged in straight line perpendicular to the glass or screen walls, such that the difference among rows of pots and the distance from the glass wall are expected to be the two major sources of variability among the experimental pots.
  • Laboratory trials with replication over time, such that the difference among experimental units conducted at the same time and among those conducted over time constitute the two known sources of variability.
  • Useful in animal nutrition studies. As in nutrition trials on dairy cattle, only a few cows may be available for financial reasons.

Restrictions

The design has important restrictions: the square order must be feasible, treatment-by-row and treatment-by-column interactions are not separately estimable with one observation per cell, and the analysis relies on an additive model with suitable residual assumptions. Plan randomization and replication carefully.

  • The requirement of Latin square design that all treatment appears only once in each row and column block also becomes a major restriction. The experiment becomes impractical if the number of treatment is very large because of large number of replications required.
  • On the other hand if the number of treatment is small, the degree of freedom associated with experimental error becomes too small for the error to be reliably estimated.
  • In agricultural experiments where the land requirement is rigid then the actual layout in the field is laborious and approach to the central plots becomes difficult.
  • Due to these restrictions the Latin square design is practically being used in experiments only where the number of treatments is not less than four and not greater than eight. Despite of its great potential for controlling experimental error this design is not being used widely in agricultural experiments.
  • If there are missing observations in the experiment then the analysis becomes complicated.

Randomization

Randomize rows, columns, and treatment labels while preserving the Latin-square condition that each treatment occurs once per row and once per column. Use a valid randomization procedure and retain the allocation record.

Table 1: Systematic arrangement for a 4 x 4 Latin Square
A B C D
B C D A
C D A B
D A B C

Randomize the order of rows

Randomly permute the row order using a reproducible random seed and document the resulting order. Randomization should be performed before treatment allocation and field operations.

  • \(4^{th}\) row is placed \(1^{st}\)
  • \(3^{rd}\) row is placed \(2^{nd}\)
  • \(1^{st}\) row is placed \(3^{rd}\) and
  • \(2^{nd}\) row is placed \(4^{th}\)
Random numbers Ranked order of rows
0.910 4
0.843 3
0.324 1
0.679 2
Table 2: Before randomizing rows
A B C D
B C D A
C D A B
D A B C
Table 3: After randomizing rows
D A B C
C D A B
A B C D
B C D A

Randomize the order of columns

Randomize the column order independently, then verify that the square structure remains intact. Check that each treatment will occur once in every row and column after the permutations.

Apply the selected column permutation consistently to the entire square. The table should show the final randomized layout, not only the permutation instructions.

Random numbers Ranked order of columns
0.628 2
0.871 3
0.158 1
0.947 4
Table 4: Before randomizing columns
D A B C
C D A B
A B C D
B C D A
Table 5: After randomizing columns
A B D C
D A C B
B C A D
C D B A

Randomize the order of treatments

Randomly map treatment labels to the square symbols, then verify the one-per-row and one-per-column condition for every treatment before conducting the experiment.

Random numbers Ranked order of treatments
0.039 1
0.718 4
0.569 3
0.182 2
Table 6: Assigning treatments’ labels randomly
A B C D
T1 T4 T3 T2
Table 7: Treatments allocation in Latin Square
T1 T4 T2 T3
T2 T1 T3 T4
T4 T3 T1 T2
T3 T2 T4 T1

The example analyzes wheat-variety yields from a four-by-four Latin square intended to control two directional fertility gradients. Confirm that the field layout and randomization actually followed this design.

Importing data

Save any existing workspace objects before clearing them. Resetting the session is optional; closing graphics devices and clearing the console do not alter the imported data.

rm(list = ls(all = TRUE))
graphics.off()
shell("cls")

Import the workbook with readxl::read_excel(), specifying the path and whether the first row contains variable names. Confirm that the file includes row, column, treatment, and response fields.

library(readxl)

data = read_excel(path = "E:/Youtube Channel/Agron Info Tech/Lectures/Data Analysis/23 LSD analysis in R/data-LS Design.xlsx",
                  col_names = TRUE)

Viewing data

Use head() and str() to inspect the imported data. A data viewer is useful for inspection, but avoid manual editing that is not recorded in the analysis script.

head(data)
# # A tibble: 6 x 4
#     Row Column Varieties Yield
#   <dbl>  <dbl> <chr>     <dbl>
# 1     1      1 B          1.64
# 2     1      2 D          1.21
# 3     1      3 C          1.42
# 4     1      4 A          1.34
# 5     2      1 C          1.48
# 6     2      2 A          1.18

Verify the variables structure

Check that row, column, and treatment are categorical factors and that yield is numeric. Verify the number of levels and confirm that each row-by-column cell contains exactly one treatment observation.

str(data)
# tibble [16 x 4] (S3: tbl_df/tbl/data.frame)
#  $ Row      : num [1:16] 1 1 1 1 2 2 2 2 3 3 ...
#  $ Column   : num [1:16] 1 2 3 4 1 2 3 4 1 2 ...
#  $ Varieties: chr [1:16] "B" "D" "C" "A" ...
#  $ Yield    : num [1:16] 1.64 1.21 1.42 1.34 1.48 ...

Convert the design labels to factors where necessary. The example uses attach(); explicit data-frame references make the model formula clearer and reduce the chance of variable-name conflicts.

data$Row <- as.factor(data$Row)
data$Column <- as.factor(data$Column)
data$Varieties = as.factor(data$Varieties)
str(data)
# tibble [16 x 4] (S3: tbl_df/tbl/data.frame)
#  $ Row      : Factor w/ 4 levels "1","2","3","4": 1 1 1 1 2 2 2 2 3 3 ...
#  $ Column   : Factor w/ 4 levels "1","2","3","4": 1 2 3 4 1 2 3 4 1 2 ...
#  $ Varieties: Factor w/ 4 levels "A","B","C","D": 2 4 3 1 3 1 4 2 1 3 ...
#  $ Yield    : num [1:16] 1.64 1.21 1.42 1.34 1.48 ...
attach(data)

Apply Latin Square model

Fit an additive model with row, column, and treatment terms. The Latin-square model does not estimate treatment-by-row or treatment-by-column interactions; inspect residuals and verify model assumptions before interpreting the treatment test.

model <- lm(formula = Yield ~ Row + Column + Varieties)
anova(model)
# Analysis of Variance Table
# 
# Response: Yield
#           Df  Sum Sq  Mean Sq F value   Pr(>F)   
# Row        3 0.03015 0.010052  0.4654 0.716972   
# Column     3 0.82734 0.275781 12.7692 0.005148 **
# Varieties  3 0.42684 0.142281  6.5879 0.025092 * 
# Residuals  6 0.12958 0.021597                    
# ---
# Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Mean separation test

The ANOVA table evaluates whether treatment means differ after accounting for row and column blocking. A significant treatment F test indicates evidence that not all means are equal, but it does not identify which pairs differ.

Use follow-up comparisons only when they address the research question and follow the model. The example uses Fisher’s LSD, which can have an elevated family-wise false-positive rate when many pairs are compared. State the method and adjustment, and report estimated differences with uncertainty where possible.

If you type model(aov or lm) in y argument then the variable name for trt argument should be written in quotations else quotations are not required
library(agricolae)
# LSD test
LSD.test(y = model,
         trt = "Varieties",
         DFerror = model$df.residual,
         MSerror = deviance(model)/model$df.residual,
         alpha = 0.05,
         group = TRUE,
         console = TRUE)
# 
# Study: model ~ "Varieties"
# 
# LSD t Test for Yield 
# 
# Mean Square Error:  0.0215974 
# 
# Varieties,  means and individual ( 95 %) CI
# 
#     Yield       std r       LCL     UCL   Min   Max
# A 1.46375 0.2386900 4 1.2839503 1.64355 1.185 1.670
# B 1.47125 0.2095382 4 1.2914503 1.65105 1.290 1.665
# C 1.06750 0.4426153 4 0.8877003 1.24730 0.660 1.475
# D 1.33875 0.1795538 4 1.1589503 1.51855 1.180 1.565
# 
# Alpha: 0.05 ; DF Error: 6
# Critical Value of t: 2.446912 
# 
# least Significant Difference: 0.2542752 
# 
# Treatments with the same letter are not significantly different.
# 
#     Yield groups
# B 1.47125      a
# A 1.46375      a
# D 1.33875      a
# C 1.06750      b
The results showed that varieties B, A and D were statistically at par and yielded more than variety C.


Download data file — Click_here

Download Rscript — Download Rscript


Download R program — Click_here

Download R studio — Click_here


Comments

Post a Comment