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 follow.
# load data into a data frame
dat12<-read.csv("https://raw.githubusercontent.com/forestwhite/RStatistics/main/FlippedAssignment12.csv", header=TRUE)
names(dat12) <- sub('X', '', names(dat12))
dat12
## Batch Day Ingredient Reaction_Time
## 1 1 1 A 8
## 2 1 2 B 7
## 3 1 3 D 1
## 4 1 4 C 7
## 5 1 5 E 3
## 6 2 1 C 11
## 7 2 2 E 2
## 8 2 3 A 7
## 9 2 4 D 3
## 10 2 5 B 8
## 11 3 1 B 4
## 12 3 2 A 9
## 13 3 3 C 10
## 14 3 4 E 1
## 15 3 5 D 5
## 16 4 1 D 6
## 17 4 2 C 8
## 18 4 3 E 6
## 19 4 4 B 6
## 20 4 5 A 10
## 21 5 1 E 4
## 22 5 2 D 2
## 23 5 3 B 3
## 24 5 4 A 8
## 25 5 5 C 8
Upload an RMarkdown file that answers the following …
Yes. First it has an equal number blocking variants and treatments, 5 x 5 x 5. Second, there is no row nor column with the same sequence of batch, day, and ingredient
pIngredient = 0.0004877 < 0.05 = α, so we can reject the null hypothesis and the choice of ingredient is significant after removing nuisance factors by using a block design.The nuisance variables both have P-values > 0.05, so we try analysis without the blocks and pIngredient non-blocking = 7.672e-05 < 0.05 = α, so we can reject the null hypothesis and the choice of ingredient is significant even without blocking. the two categories, Batch and Days, have calculated p-values greater than 0.05 in the block design (0.3476182 and 0.4550143, respectively) so neither has significant effect on the variance.
# change block variables into factors
dat12$Batch <- as.factor(dat12$Batch)
dat12$Day <- as.factor(dat12$Day)
dat12$Ingredient <- as.factor(dat12$Ingredient)
str(dat12)
## 'data.frame': 25 obs. of 4 variables:
## $ Batch : Factor w/ 5 levels "1","2","3","4",..: 1 1 1 1 1 2 2 2 2 2 ...
## $ Day : Factor w/ 5 levels "1","2","3","4",..: 1 2 3 4 5 1 2 3 4 5 ...
## $ Ingredient : Factor w/ 5 levels "A","B","C","D",..: 1 2 4 3 5 3 5 1 4 2 ...
## $ Reaction_Time: int 8 7 1 7 3 11 2 7 3 8 ...
# Apply analysis of variance model
model12 <- lm(Reaction_Time ~ Batch+Day+Ingredient, dat12)
anova(model12)
## Analysis of Variance Table
##
## Response: Reaction_Time
## Df Sum Sq Mean Sq F value Pr(>F)
## Batch 4 15.44 3.860 1.2345 0.3476182
## Day 4 12.24 3.060 0.9787 0.4550143
## Ingredient 4 141.44 35.360 11.3092 0.0004877 ***
## Residuals 12 37.52 3.127
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#Apply analysis of variance without blocking
model12_nb <- lm(Reaction_Time ~ Ingredient, dat12)
anova(model12_nb)
## Analysis of Variance Table
##
## Response: Reaction_Time
## Df Sum Sq Mean Sq F value Pr(>F)
## Ingredient 4 141.44 35.36 10.847 7.672e-05 ***
## Residuals 20 65.20 3.26
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Complete R code used in this analysis.
# load data into a data frame
# load data into a data frame
dat12<-read.csv("https://raw.githubusercontent.com/forestwhite/RStatistics/main/FlippedAssignment12.csv", header=TRUE)
names(dat12) <- sub('X', '', names(dat12))
dat12
# change block variables into factors
dat12$Batch <- as.factor(dat12$Batch)
dat12$Day <- as.factor(dat12$Day)
dat12$Ingredient <- as.factor(dat12$Ingredient)
str(dat12)
# Apply analysis of variance model
model12 <- lm(Reaction_Time ~ Batch+Day+Ingredient, dat12)
anova(model12)
#Apply analysis of variance without blocking
model12_nb <- lm(Reaction_Time ~ Ingredient, dat12)
anova(model12_nb)