# Enter data
Day <- c(1,1,1,1,1, 2,2,2,2,2, 3,3,3,3,3, 4,4,4,4,4, 5,5,5,5,5)
Batch <- c(1,2,3,4,5, 1,2,3,4,5, 1,2,3,4,5, 1,2,3,4,5, 1,2,3,4,5)
Ingredient <- c("A","C","B","D","E", "B","E","A","C","D", "D","A","C","E","B", 
                "C","D","E","B","A", "E","B","D","A","C")
Time <- c(8,11,4,6,4, 7,2,9,8,2, 1,7,10,6,3, 7,3,1,6,10, 3,8,5,8,8)

#12.1

Answer: This is a valid Latin Square. Each ingredient appears exactly once in each day and exactly once in each batch.

#12.2

Model: Y = μ + α + β + τ + ε

Where: - Y = reaction time - μ = overall mean - α = day effect - β = batch effect
- τ = ingredient effect - ε = error

Hypotheses: - H0: All ingredients have the same effect - Ha: At least one ingredient differs


#12.3

#model
model <- aov(Time ~ factor(Day) + factor(Batch) + factor(Ingredient))
summary(model)
##                    Df Sum Sq Mean Sq F value  Pr(>F)   
## factor(Day)         4   6.64    1.66   0.396 0.80785   
## factor(Batch)       4   8.24    2.06   0.491 0.74244   
## factor(Ingredient)  4 141.44   35.36   8.432 0.00177 **
## Residuals          12  50.32    4.19                   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#plotting
boxplot(Time ~ Ingredient, 
        xlab = "Ingredient", 
        ylab = "Reaction Time")

Answer: The ANOVA results show that the Ingredient factor has an F-value of 8.432 with a p-value of 0.00177. Since this p-value is less than our significance level of α = 0.05, we reject the null hypothesis