Yes, it is a valid Latin Square since all different ingredients(A ,B ,C ,D,E) appears in each row and each column uniquely and there isn’t same ingredients within a same row or same column.
\[ Y_{ijk}=\mu+\tau_{i}+\beta_{j}+\alpha_{k}+\epsilon_{ijk} \] Where,
µ = Grand Mean
τi = Treatment effect
βj = Block-1 effect
αk = Block-2 effect
εijk = Random error
i = number of treatments
j = number of block-1
k = number of block-2
#Hypothesis:
All treatment effects are equal:
\[ H_0 : \tau_A = \tau_B = \tau_C = \tau_D = \tau_E = 0 \]
At least one treatment effect differs.
\[ H_1 : \text{At least one } \tau_i \neq 0 \]
df <- expand.grid(seq(1, 5), seq(1, 5))
colnames(df) <- c("Day", "Batch")
# Convert Day and Batch to factor type
df$Day <- as.factor(df$Day)
df$Batch <- as.factor(df$Batch)
# Check structure
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" ...
# Add Ingredient column
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"
)
# Add Response values
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$Ingredient <- as.factor(df$Ingredient)
str(df)
## 'data.frame': 25 obs. of 4 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 ...
## $ Ingredient: Factor w/ 5 levels "A","B","C","D",..: 1 2 4 3 5 3 5 1 4 2 ...
## $ Response : num 8 7 1 7 3 11 2 7 3 8 ...
## - 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
## 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
#model <- aov(df$Response~ df$Day + df$Batch + df$Ingredient)
model <- aov(Response~ Day + Batch + Ingredient, data = df)
summary(model)
## Df Sum Sq Mean Sq F value Pr(>F)
## Day 4 12.24 3.06 0.979 0.455014
## Batch 4 15.44 3.86 1.235 0.347618
## Ingredient 4 141.44 35.36 11.309 0.000488 ***
## Residuals 12 37.52 3.13
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##The P- value for Ingrediants is < 0.05 , so we can reject null hypothesis ##Therefore different ingrediants significatly affect the time of reactions., the day and batch was not significatly affect to bias the result.
df <- expand.grid(seq(1, 5), seq(1, 5))
colnames(df) <- c("Day", "Batch")
# Convert Day and Batch to factor type
df$Day <- as.factor(df$Day)
df$Batch <- as.factor(df$Batch)
# Check structure
str(df)
# Add Ingredient column
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"
)
# Add Response values
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$Ingredient <- as.factor(df$Ingredient)
str(df)
df
#model <- aov(df$Response~ df$Day + df$Batch + df$Ingredient)
model <- aov(Response~ Day + Batch + Ingredient, data = df)
summary(model)