We believe that it is a valid Latin Square because it has two sources of variability, which is the number of days and batches. The observations are not repeating, which include both rows and columns.
\(X_{ij}=\mu+\tau_i+\varepsilon_{ijk}+\beta_j+\alpha_k\)
Null Hypothesis:
\(H_{0}:\tau _{i}=0\)
Alternating Hypothesis:
\(H_{a}:\tau _{i}\neq 0\)
df<-expand.grid(seq(1,5),seq(1,5))
colnames(df)<-c("Day","Batch")
df$Day<-as.factor(df$Day)
df$Batch<-as.factor(df$Batch)
str(df)
## 'data.frame': 25 obs. of 2 variables:
## $ Day : Factor w/ 5 levels "1","2","3","4",..: 1 2 3 4 5 1 2 3 4 5 ...
## $ Batch: Factor w/ 5 levels "1","2","3","4",..: 1 1 1 1 1 2 2 2 2 2 ...
## - attr(*, "out.attrs")=List of 2
## ..$ dim : int [1:2] 5 5
## ..$ dimnames:List of 2
## .. ..$ Var1: chr [1:5] "Var1=1" "Var1=2" "Var1=3" "Var1=4" ...
## .. ..$ Var2: chr [1:5] "Var2=1" "Var2=2" "Var2=3" "Var2=4" ...
df$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")
df$Response<-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)
df
## Day Batch Ingredient Response
## 1 1 1 A 8
## 2 2 1 B 7
## 3 3 1 D 1
## 4 4 1 C 7
## 5 5 1 E 3
## 6 1 2 C 11
## 7 2 2 E 2
## 8 3 2 A 7
## 9 4 2 D 3
## 10 5 2 B 8
## 11 1 3 B 4
## 12 2 3 A 9
## 13 3 3 C 10
## 14 4 3 E 1
## 15 5 3 D 5
## 16 1 4 D 6
## 17 2 4 C 8
## 18 3 4 E 6
## 19 4 4 B 6
## 20 5 4 A 10
## 21 1 5 E 4
## 22 2 5 D 2
## 23 3 5 B 3
## 24 4 5 A 8
## 25 5 5 C 8
df$Ingredient<-as.factor(df$Ingredient)
aov.model<-aov(df$Response ~ df$Ingredient)
summary(aov.model)
## Df Sum Sq Mean Sq F value Pr(>F)
## df$Ingredient 4 141.4 35.36 10.85 7.67e-05 ***
## Residuals 20 65.2 3.26
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
The null hypothesis is rejected because the p-value (7.67e-05) is much less than alpha. The different ingredients have certain effects on the reaction time of the chemical reactions.