The effect of five different ingredients (A, B, C, D, E) on the reaction time of a chemical process is being studied. Each batch of new material is only large enough to permit five runs to be made. Furthermore, each run requires approximately 1.5 hours, so only five runs can be made in one day. The experimenter decides to run the experiment as a Latin square so that day and batch effects may be systematically controlled. She obtains the data that follows.
This is a valid Latin Square because each letter appears exactly once in each row and each column.
\[Y_{ijk} = \mu + \alpha_i + \tau_j + \beta_k + \epsilon_{ijk}\] Where:
\(Y_{ijk}\) = The response observation (reaction time) in the \(i\)-th row (Batch), \(k\)-th column (Day), and receiving the \(j\)-th treatment (Ingredient).
\(\mu\) = Overall mean.
\(\alpha_i\) = Effect of the \(i\)-th row / Batch (\(i = 1, 2, 3, 4, 5\)).
\(\tau_j\) = Effect of the \(j\)-th treatment / Ingredient (\(j = A, B, C, D, E\)).
\(\beta_k\) = Effect of the \(k\)-th column / Day (\(k = 1, 2, 3, 4, 5\)).
\(\epsilon_{ijk}\) = Random error component, assumed \(\text{N}(0, \sigma^2)\).
Hypothesis:
Null Hypothesis (\(H_0\)): \(\tau_A = \tau_B = \tau_C = \tau_D = \tau_E = 0\) (All five ingredients produce equivalent mean reaction time).
Alternative Hypothesis (\(H_1\)): At least one \(\tau_j \neq 0\) (At least one ingredient produces a different mean reaction time).
# Input data
batch <- factor(rep(1:5, each = 5))
day <- factor(rep(1:5, times = 5))
# Data - treatments
ingredient <- 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"))
# Reaction Time
reaction_time <- 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_lsd <- data.frame(batch, day, ingredient, reaction_time)
# Latin Square - aov
model_lsd <- aov(reaction_time ~ batch + day + ingredient, data = df_lsd)
summary(model_lsd)
## 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
## 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
For a alpha = 0.05:
Because we fail in reject H0 regarding the Batches an the Days, this implies that there are no significant differences among theses items.
However, because of the Ingredients have a p=value < 0.05, this means that the five ingredients have a statistically significant effect on the reaction time of the process.
knitr::opts_chunk$set(echo = TRUE, warning=FALSE, message = FALSE)
# Input data
batch <- factor(rep(1:5, each = 5))
day <- factor(rep(1:5, times = 5))
# Data - treatments
ingredient <- 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"))
# Reaction Time
reaction_time <- 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_lsd <- data.frame(batch, day, ingredient, reaction_time)
# Latin Square - aov
model_lsd <- aov(reaction_time ~ batch + day + ingredient, data = df_lsd)
summary(model_lsd)