knitr::opts_chunk$set(echo = TRUE)

IE 5342 Flipped Assignment 12

Latin Squares

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. 

1. Is this a valid Latin Square? (explain)

Well yes, a Latin square means that each ingredient (A, B, C, D, E) should show up once per row and once per column, without repeating itself. This true in our case.

2. Write the model equation.

Linear effects equation:

\[ Y_{ijk} = \mu + \alpha_i + \beta_j + \gamma_k + \epsilon_{ijk} \]

  • 𝑌ijk is the reaction time for the i-th day, j-th batch, and k-th ingredient

  • μ is the grand mean

  • α is the effect of the i-th day (because apparently, days matter)

  • β is the effect of the j-th batch (because batches have feelings too)

  • γ is the effect of the k-th ingredient (the real diva here)

  • ϵ is the random error (because nobody’s perfect)

3. Analyze the data from this experiment. (use α=0.05)

So, after running the ANOVA, the F critical value is sitting at 3.25. Now, for day and batch? Their F values (0.979 and 1.235) couldn’t even hit that mark, meaning their effect on the reaction time is not significant—basically, they’re just there for the ride. But when it comes to ingredients? Oh, they came to play! With an F value of 11.3, blowing past the 3.25 threshold, it’s clear that ingredients are the real MVP here, having a significant effect on the reaction time. So, while day and batch are just chilling, ingredients are out here making things happen. 😎

reaction_time <- c(8, 7, 1, 7, 3,   # Batch 1
                   11, 2, 7, 3, 8,  # Batch 2
                   4, 9, 10, 1, 5,  # Batch 3
                   6, 8, 6, 6, 10,  # Batch 4
                   4, 2, 3, 8, 8)   # Batch 5

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"))

batch <- factor(rep(1:5, each=5))
day <- factor(rep(1:5, times=5))

data <- data.frame(day, batch, ingredient, reaction_time)

aov <- aov(reaction_time~day+batch+ingredient)
summary(aov)
##             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
batch_crit_f <- qf(0.95, 4, 12)
batch_crit_f
## [1] 3.259167
day_crit_f <- qf(0.95, 4, 12)
day_crit_f
## [1] 3.259167
ingrediant_crit_f <- qf(0.95, 4, 12)
ingrediant_crit_f
## [1] 3.259167