Problem 4.3

statistical model: \(y_{ij}\) = \(\mu\) + \(\tau_{i}\) + \(\beta_{j}\) + \(\epsilon_{ij}\)
null hypothesis: All means are equal, \(\tau_{i}\) = 0
alternative hypothesis: At least one mean differs, \(\tau_{i}\) \(\neq\) 0
library(GAD)
## Warning: package 'GAD' was built under R version 4.0.5
## Loading required package: matrixStats
## Warning: package 'matrixStats' was built under R version 4.0.5
## Loading required package: R.methodsS3
## Warning: package 'R.methodsS3' was built under R version 4.0.3
## R.methodsS3 v1.8.1 (2020-08-26 16:20:06 UTC) successfully loaded. See ?R.methodsS3 for help.
chemical <- c(rep(1,5),rep(2,5),rep(3,5),rep(4,5))
chemical <- as.fixed(chemical)
bolt <- c(rep(seq(1,5),4))
bolt <- as.fixed(bolt)
obs <- c(73,68,74,71,67,73,67,75,72,70,75,68,78,73,68,73,71,75,75,69)
model <- lm(obs~chemical+bolt)
gad(model)
## Analysis of Variance Table
## 
## Response: obs
##          Df Sum Sq Mean Sq F value    Pr(>F)    
## chemical  3  12.95   4.317  2.3761    0.1211    
## bolt      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
The p-value of the chemicals is 0.1211, which is greater than \(\alpha\) = 0.05. This indicates that the null hypothesis cannot be rejected. Additionally, the p-value of the block (bolt) is much smaller than alpha, implying that the bolt is indeed a significant source of nuisance variability.

Problem 4.16

mu <- mean(obs)
tau <- c(rep(1,4))
beta <- c(rep(1,4))
for (i in 1:4)
{
  tau[i] <- mean(obs[((5*i)-4):(5*i)])-mu
}
beta[1] <- (obs[1]+obs[6]+obs[11]+obs[16])/4-mu
beta[2] <- (obs[2]+obs[7]+obs[12]+obs[17])/4-mu
beta[3] <- (obs[3]+obs[8]+obs[13]+obs[18])/4-mu
beta[4] <- (obs[4]+obs[9]+obs[14]+obs[19])/4-mu
beta[5] <- (obs[5]+obs[10]+obs[15]+obs[20])/4-mu
beta
## [1]  1.75 -3.25  3.75  1.00 -3.25
tau
## [1] -1.15 -0.35  0.65  0.85
\(\hat{\mu}\) = 71.75, \(\hat{\tau_{1}}\) = -1.15 , \(\hat{\tau_{2}}\) = -0.35, \(\hat{\tau_{3}}\) = 0.65 ,\(\hat{\tau_{4}}\) = 0.85, \(\hat{\beta_{1}}\) = 1.75 , \(\hat{\beta_{2}}\) = -3.25 ,\(\hat{\beta_{3}}\) = 3.75 , \(\hat{\beta_{4}}\) = 1.00, \(\hat{\beta_{4}}\) = -3.25

Problem 4.22

null hypothesis: The ingredients have no affect on the reaction time, \(\tau_{j}\) = 0
alternative hypothesis: The ingredients have an affect on the reaction time, \(\tau_{j}\) \(\neq\) 0
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")
ingredient <- as.factor(ingredient)
batch <- c(rep(1,5),rep(2,5),rep(3,5),rep(4,5),rep(5,5))
batch <- as.factor(batch)
day <- c(rep(seq(1,5),5))
day <- as.factor(day)
aov.model <-aov(obs~batch+day+ingredient)
summary(aov.model)
##             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
The p-value of the ingredient is 0.000488, which is significantly lower than that of \(\alpha\) = 0.05. This indicates that we reject the null hypothesis. Additionally, the p-values of the two blocks (batch & day) are much greater than alpha, indicating that they are sources of nuisance variability. In conclusion, the ingredients do have an effect on the reaction time.

R Code

library(GAD)
chemical <- c(rep(1,5),rep(2,5),rep(3,5),rep(4,5))
chemical <- as.fixed(chemical)
bolt <- c(rep(seq(1,5),4))
bolt <- as.fixed(bolt)
obs <- c(73,68,74,71,67,73,67,75,72,70,75,68,78,73,68,73,71,75,75,69)
model <- lm(obs~chemical+bolt)
gad(model)
mu <- mean(obs)
tau <- c(rep(1,4))
beta <- c(rep(1,4))
for (i in 1:4)
{
  tau[i] <- mean(obs[((5*i)-4):(5*i)])-mu
}
beta[1] <- (obs[1]+obs[6]+obs[11]+obs[16])/4-mu
beta[2] <- (obs[2]+obs[7]+obs[12]+obs[17])/4-mu
beta[3] <- (obs[3]+obs[8]+obs[13]+obs[18])/4-mu
beta[4] <- (obs[4]+obs[9]+obs[14]+obs[19])/4-mu
beta[5] <- (obs[5]+obs[10]+obs[15]+obs[20])/4-mu
beta
tau
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")
ingredient <- as.factor(ingredient)
batch <- c(rep(1,5),rep(2,5),rep(3,5),rep(4,5),rep(5,5))
batch <- as.factor(batch)
day <- c(rep(seq(1,5),5))
day <- as.factor(day)
aov.model <-aov(obs~batch+day+ingredient)
summary(aov.model)