yes, Each ingredient (A–E) appears exactly once in each Day (row) and once in each Batch (column).
Y(ijk) = mu + alpha(i) + beta(j) + tau(k) + error(ijk)
Y(ijk) = observed reaction time
mu = overall mean
alpha(i) = effect of the i-th Day (row)
beta(j) = effect of the j-th Batch (column)
tau(k) = effect of the k-th Ingredient (treatment)
error(ijk) = random error, assumed normally distributed
# ---- Data entry ----
Day <- rep(1:5, each = 5)
Batch <- rep(1:5, times = 5)
Ingredient <- c("A","B","D","C","E",
"C","E","A","D","B",
"B","A","C","E","D",
"D","C","E","B","A",
"E","D","B","A","C")
Time <- c(8,7,1,7,3,
11,2,7,3,8,
4,9,10,1,5,
6,8,6,6,10,
4,2,3,8,8)
dat <- data.frame(Day = factor(Day),
Batch = factor(Batch),
Ingredient = factor(Ingredient),
Time = Time)
dat
## Day Batch Ingredient Time
## 1 1 1 A 8
## 2 1 2 B 7
## 3 1 3 D 1
## 4 1 4 C 7
## 5 1 5 E 3
## 6 2 1 C 11
## 7 2 2 E 2
## 8 2 3 A 7
## 9 2 4 D 3
## 10 2 5 B 8
## 11 3 1 B 4
## 12 3 2 A 9
## 13 3 3 C 10
## 14 3 4 E 1
## 15 3 5 D 5
## 16 4 1 D 6
## 17 4 2 C 8
## 18 4 3 E 6
## 19 4 4 B 6
## 20 4 5 A 10
## 21 5 1 E 4
## 22 5 2 D 2
## 23 5 3 B 3
## 24 5 4 A 8
## 25 5 5 C 8
# ---- Latin Square ANOVA ----
dat_latin <- aov(Time ~ Ingredient + Day + Batch, data = dat)
summary(dat_latin)
## Df Sum Sq Mean Sq F value Pr(>F)
## Ingredient 4 141.44 35.36 11.309 0.000488 ***
## Day 4 15.44 3.86 1.235 0.347618
## Batch 4 12.24 3.06 0.979 0.455014
## Residuals 12 37.52 3.13
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
TukeyHSD(dat_latin, "Ingredient")
## Tukey multiple comparisons of means
## 95% family-wise confidence level
##
## Fit: aov(formula = Time ~ Ingredient + Day + Batch, data = dat)
##
## $Ingredient
## diff lwr upr p adj
## B-A -2.8 -6.3646078 0.7646078 0.1539433
## C-A 0.4 -3.1646078 3.9646078 0.9960012
## D-A -5.0 -8.5646078 -1.4353922 0.0055862
## E-A -5.2 -8.7646078 -1.6353922 0.0041431
## C-B 3.2 -0.3646078 6.7646078 0.0864353
## D-B -2.2 -5.7646078 1.3646078 0.3365811
## E-B -2.4 -5.9646078 1.1646078 0.2631551
## D-C -5.4 -8.9646078 -1.8353922 0.0030822
## E-C -5.6 -9.1646078 -2.0353922 0.0023007
## E-D -0.2 -3.7646078 3.3646078 0.9997349
The ANOVA shows that the Ingredient factor is significant (p = 0.000488), while Day and Batch are not significant (p = 0.347 and 0.455, respectively). This means that only the type of ingredient has a real effect on reaction time.
Tukey’s test confirms that Ingredients D and E produce significantly shorter reaction times than A and C. Ingredients D and E are not significantly different from each other, and Ingredient B shows no significant difference from any group.