This document contains the analysis of an experiment that studies the effect of five different ingredients (A, B, C, D, E) on the reaction time of a chemical process. Each batch of new material is only large enough for five runs, and only five runs can be made in one day, so the experiment is run as a Latin square with the batch and the day as the two blocking factors. First, the design is checked to confirm that it is a valid Latin square. Then the model equation is written, and finally the data is analyzed with aov() at a significance level of alpha = 0.05. All of the data manipulation, analysis and plotting is done within R.
Yes, this is a valid Latin square. A Latin square requires a p x p arrangement in which each Latin letter (treatment) occurs only once in each row and only once in each column. Here p = 5: there are 5 batches (rows), 5 days (columns) and 5 ingredients (A, B, C, D, E), and the design has 5 x 5 = 25 observations.
| Batch | Day 1 | Day 2 | Day 3 | Day 4 | Day 5 |
|---|---|---|---|---|---|
| 1 | A | B | D | C | E |
| 2 | C | E | A | D | B |
| 3 | B | A | C | E | D |
| 4 | D | C | E | B | A |
| 5 | E | D | B | A | C |
Each row contains the letters A, B, C, D and E exactly once, and each column also contains the letters A, B, C, D and E exactly once. So every ingredient is tested once in every batch and once in every day, and the design is a valid Latin square.
The linear effects model is:
\[y_{ijk} = \mu + \alpha_i + \tau_j + \beta_k + \epsilon_{ijk}, \qquad i = 1,...,5 \qquad j = 1,...,5 \qquad k = 1,...,5\]
where \(y_{ijk}\) is the reaction time in the \(i\)th batch with the \(j\)th ingredient on the \(k\)th day, \(\mu\) is the overall mean, \(\alpha_i\) is the effect of the \(i\)th batch (row block), \(\tau_j\) is the effect of the \(j\)th ingredient (treatment), \(\beta_k\) is the effect of the \(k\)th day (column block) and \(\epsilon_{ijk}\) is the random error. The model is additive, so there are no interactions between the treatment and the blocks.
The hypothesis being tested is:
\[H_0: \tau_1 = \tau_2 = \tau_3 = \tau_4 = \tau_5 = 0\] \[H_1: \tau_j \neq 0 \text{ for at least one } j\]
The observations are entered by batch (row), from day 1 to day 5, with the ingredient of each cell in the same order.
obs<-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)
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")
batch<-c(rep(1,5),rep(2,5),rep(3,5),rep(4,5),rep(5,5))
day<-c(rep(c(1,2,3,4,5),5))
ingredient<-as.factor(ingredient)
batch<-as.factor(batch)
day<-as.factor(day)
The batch and the day are converted to factors with as.factor(), so that aov() recognizes them as blocks and not as numeric variables.
boxplot(obs~ingredient,xlab="Ingredient",ylab="Reaction Time",main="Boxplot of Observations by Ingredient")
The boxplot shows that ingredients A and C have the largest reaction times (means of 8.4 and 8.8), ingredient B is in the middle (5.6), and ingredients D and E have the smallest reaction times (3.4 and 3.2).
model<-aov(obs~ingredient+batch+day)
summary(model)
## Df Sum Sq Mean Sq F value Pr(>F)
## ingredient 4 141.44 35.36 11.309 0.000488 ***
## batch 4 15.44 3.86 1.235 0.347618
## day 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
For the ingredients, the F statistic is about 11.31 with 4 and 12 degrees of freedom and a p-value of about 0.0005. Since the p-value is smaller than alpha = 0.05, we reject the null hypothesis and conclude that the ingredient has a significant effect on the reaction time of the chemical process: at least one of the five ingredients produces a different mean reaction time. Ingredients A and C give the longest reaction times, while D and E give the shortest.
The batch (F about 1.23, p-value about 0.35) and the day (F about 0.98, p-value about 0.46) have small F statistics, so in this experiment they did not add much nuisance variability. Even so, blocking on them guarantees that the comparison of the ingredients is not affected by differences between batches or days.
obs<-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)
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")
batch<-c(rep(1,5),rep(2,5),rep(3,5),rep(4,5),rep(5,5))
day<-c(rep(c(1,2,3,4,5),5))
ingredient<-as.factor(ingredient)
batch<-as.factor(batch)
day<-as.factor(day)
boxplot(obs~ingredient,xlab="Ingredient",ylab="Reaction Time",main="Boxplot of Observations by Ingredient")
model<-aov(obs~ingredient+batch+day)
summary(model)