This report captures work done for the individual homework for Week 7. R code along with the results are provided. The required homework problems were taken from “Design and Analysis of Experiments 8th Edition”:
   1) 4.3
   2) 4.16
   3) 4.22
Answers to the questions are in blue.


Problem 1 (4.3)

This is identical to the first part of the flipped assignment so I’m using the solution I developed for it here. We are studying the effect of the four chemical agents on the strength of a particular type of cloth. And, because there might be variability from one bolt to another, the chemist decided to use a randomized block design, with the bolts of cloth considered as blocks.

Setting things up:

# setup Libraries
library(knitr)
library(dplyr)
library(tidyr)
library(GAD)
# READ IN FILE
setwd("D:/R Files/")
dat <- read.csv("chemicals.csv",header=TRUE)

# PIVOT COLUMNS
dat <- pivot_longer(dat,c(Bolt1,Bolt2,Bolt3,Bolt4,Bolt5))

# SET UP VARIABLES
solution <- as.fixed(dat$Chemical)
days <- as.random(dat$name)
obs <- as.integer(dat$value)


The Linear Effects for this Model are:
\(\quad y_{ij}\) = \(\mu\) + \(\tau_i\) + \(\beta_j\) + \(\epsilon_{ij}\)

Where:
\(\tau_i\) is the effect of the \(\ i^{th}\) treatment of chemical agent used
\(\beta_j\) is the effect of the \(\ j^{th}\) block of cloth bolt used, and
\(\epsilon_{ij}\) is the random error term.

The Hypotheses we will test are:
\(\quad H_0\) : \(\tau_i\) = 0 \(\forall\) i
\(\quad H_a\) : \(\tau_i \neq\) 0for at least one \(\ i\)
\(\quad\)at a significance level of \(\alpha\) = 0.05

By running a General ANOVA Design on the linear model of chemical agents and cloth bolts, we get the following results:

## Analysis of Variance Table
## 
## Response: obs
##          Df Sum Sq Mean Sq F value    Pr(>F)    
## solution  3  12.95   4.317  2.3761    0.1211    
## days      4 157.00  39.250 21.6055 2.059e-05 ***
## Residual 12  21.80   1.817                      
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

With a p-value of 0.1211 and a significance level of 0.05, we fail to reject the Null hypothesis. There is not enough evidence to support the claim of a significant effect of the chemical agent used.


Problem 2 (4.16)

Assuming that chemical types and bolts are fixed, estimate the model parameters \(\tau_i\) and \(\beta_j\) in Problem 4.3.

From the textbook we know that the estimates are as follows:
\(\quad \hat{\tau_i}\) = \(\bar y_{i\cdot}\) - \(\bar y_{\cdot\cdot}\) \(\ i\) = 1, 2, 3, 4
\(\quad \hat{\beta_j}\) = \(\bar y_{\cdot j}\) - \(\bar y_{\cdot\cdot}\) \(\ i\) = 1, 2, 3, 4, 5

Thus: \(\quad \hat{\tau_1}\) = 70.6 - 71.75 = -1.15 \(\quad \hat{\tau_2}\) = 71.4 - 71.75 = -0.35 \(\quad \hat{\tau_3}\) = 72.4 - 71.75 = 0.65 \(\quad \hat{\tau_4}\) = 72.6 - 71.75 = 0.85 and
\(\quad \hat{\beta_1}\) = 73.5 - 71.75 = 1.75 \(\quad \hat{\beta_2}\) = 68.5 - 71.75 = -3.25 \(\quad \hat{\beta_3}\) = 75.5 - 71.75 = 3.75 \(\quad \hat{\beta_4}\) = 72.75 - 71.75 = 1.00 \(\quad \hat{\beta_5}\) = 68.5 - 71.75 = -3.25


Problem 3 (4.22)

We will use a Latin Squares design to analyze the effect of five different ingredients on the reaction time of a chemical process under study where the day and batch effects may be systematically controlled. The data table is provided in the book.

The Linear Effects for this Model are:
\(\quad x_{ijk}\) = \(\mu\) + \(\tau_i\) + \(\beta_j\) + \(\alpha_k\) + \(\epsilon_{ijk}\)

Where:
\(\tau_i\) is the effect of the \(\ i^{th}\) treatment of ingredient used
\(\beta_j\) is the effect of the \(\ j^{th}\) block on batch,
\(\alpha_k\) is the effect of the \(\ j^{th}\) block on day, and
\(\epsilon_{ijk}\) is the random error term.

The Hypotheses we will test are:
\(\quad H_0\) : \(\tau_i\) = 0 \(\forall\) i
\(\quad H_a\) : \(\tau_i \neq\) 0for at least one \(\ i\)
\(\quad\)at a significance level of \(\alpha\) = 0.05

Setting things up and running the General ANOVA Model, we get the following:

# READ IN FILE
setwd("D:/R Files/")
datLatin <- read.csv("LatinSquares.csv",header=TRUE)

# SET UP VARIABLES
batch <- as.factor(datLatin$Batch)
day <- as.factor(datLatin$Day)
ingredient <- as.factor(datLatin$Ingredient)
observation <- as.factor(datLatin$Observation)

My_ANOVA_Input_Table <- as.data.frame(cbind(batch,day,ingredient,observation))
names(My_ANOVA_Input_Table) <- c("Batch","Day","Ingredient","ReactionTime") 
My_ANOVA_Input_Table$Batch <- as.factor(My_ANOVA_Input_Table$Batch)
My_ANOVA_Input_Table$Day <- as.factor(My_ANOVA_Input_Table$Day)
My_ANOVA_Input_Table$Ingredient <- as.factor(My_ANOVA_Input_Table$Ingredient)
My_ANOVA_Input_Table$ReactionTime <- as.integer(My_ANOVA_Input_Table$ReactionTime)
Latinmodel <- aov(My_ANOVA_Input_Table$ReactionTime ~ My_ANOVA_Input_Table$Batch + 
               My_ANOVA_Input_Table$Day + My_ANOVA_Input_Table$Ingredient , 
             data= My_ANOVA_Input_Table)
summary(Latinmodel)
##                                 Df Sum Sq Mean Sq F value   Pr(>F)    
## My_ANOVA_Input_Table$Batch       4  15.44    3.86   1.235 0.347618    
## My_ANOVA_Input_Table$Day         4  12.24    3.06   0.979 0.455014    
## My_ANOVA_Input_Table$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

With the following p-values:
\(\quad\) Batch p-value \(\approx\) 0.35
\(\quad\) Day p-value \(\approx\) 0.46
\(\quad\) Ingredient p-value \(\approx\) 0.0005
We can reject the null hypothesis and state that Ingredient is a significant factor driving reaction times. Batch and Day are not significant to an alpha of 0.05.