Yes, it is a valid Latin Square, because the observations are not repeated in each row and column. This provides orthogonality to the experiment.
The model equation is
\[ Y_{i,j,k} = \mu + \alpha_{i} +\beta_{j} + \gamma_{k} + \epsilon_{i,j,k} \]
df<-expand.grid(seq(1,5),seq(1,5))# create the data frame
colnames(df)<-c("Day","Batch") # rename the column names
df$Day<-as.factor(df$Day) # convert the data into factor
df$Batch<-as.factor(df$Batch) # convert the data into factor
df$Factor <- 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") # input the factors
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) # input the response
df$factor <- as.factor(df$Factor) # convert the data into factor
str(df) #confirm all the data is factor
## 'data.frame': 25 obs. of 5 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 ...
## $ Factor : chr "A" "B" "D" "C" ...
## $ Response: num 8 7 1 7 3 11 2 7 3 8 ...
## $ factor : Factor w/ 5 levels "A","B","C","D",..: 1 2 4 3 5 3 5 1 4 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" ...
model <- lm(Response~Batch+Day+Factor, data = df) # create the model
aov <- aov(model) # anova test
summary(aov) #showing result
## Df Sum Sq Mean Sq F value Pr(>F)
## Batch 4 15.44 3.86 1.235 0.347618
## Day 4 12.24 3.06 0.979 0.455014
## Factor 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
Since our ingrediants P-Value is 0.000488, very small compared to the sig level of 0.05, therefore we will reject the Null Hypothesis. So, we conclude that different ingredients have certain effect on reaction time of a chemical process. The Factor(Ingredient) has a significant effect on the reaction time.
df<-expand.grid(seq(1,5),seq(1,5))# create the data frame
colnames(df)<-c("Day","Batch") # rename the column names
df$Day<-as.factor(df$Day) # convert the data into factor
df$Batch<-as.factor(df$Batch) # convert the data into factor
df$Factor <- 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") # input the factors
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) # input the response
df$factor <- as.factor(df$Factor) # convert the data into factor
str(df) #confirm all the data is factor
model <- lm(Response~Batch+Day+Factor, data = df) # create the model
aov <- aov(model) # anova test
summary(aov) #showing result