Setup

Load Libraries Into Session

# setup Libraries
library(dplyr)
library(knitr)
library(kableExtra)
library(tidyr)
library(GAD)

Problem 4.3

A chemist wishes to test the effect of four chemical agents on the strength of a particular type of cloth. Because there might be variability from one bolt to another, the chemist decides to use a randomized block design, with the bolts of cloth considered as blocks. She selects five bolts and applies all four chemicals in random order to each bolt. The resulting tensile strengths follow.

ChemicalType 1 2 3 4 5
1 73 68 74 71 67
2 73 67 75 72 70
3 75 68 78 73 68
4 73 71 75 75 69

Analyze the data from this experiment (use \(\alpha=0.05\)) and draw appropriate conclusions.

Chemical <-  c(rep(1,5),rep(2,5),rep(3,5),rep(4,5))
bolts <-  c(seq(1,5),seq(1,5),seq(1,5),seq(1,5))
obs <-  c(73,68,74,71,67,
          73,67,75,72,70,
          75,68,78,73,68,
          73,71,75,75,69)

Chemical <- as.fixed(Chemical)
bolts <- as.random(bolts)
obs <- as.integer(obs)

Linear Effects Model

\(y_{ij}\) = \(\mu\) + \(\tau_i\) + \(\beta_j\) + \(\epsilon_{ij}\)

Hypotheses

\(H_0\): \(\tau_i\) = 0 \(\forall\) i
\(H_a\): \(\tau_i \neq\) 0 for at least one \(\ i\)

Setting Up Linear Model and Running GAD

ClothModel <- lm(obs~Chemical+bolts)
gad(ClothModel)
## 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    
## bolts     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

Conclusions

The GAD function results in a p-value of \(0.1211\), meaning we fail to reject \(H_0\) and conclude that the chemical agent does not affect the strength of the cloth.

Problem 4.16

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

Recall Data Table from Problem 4.3:

ChemicalType 1 2 3 4 5
1 73 68 74 71 67
2 73 67 75 72 70
3 75 68 78 73 68
4 73 71 75 75 69

Tau and Beta Estimation Equations

Equations 4.26 in the book. I was not able to figure out how to create the “dot” in R, such as the dot in “y bar i dot”.

Estimating Tau_i

Chem1obs <- c(73,68,74,71,67)
Chem2obs <- c(73,67,75,72,70)
Chem3obs <- c(75,68,78,73,68)
Chem4obs <- c(73,71,75,75,69)
Chemobs <- c(Chem1obs,Chem2obs,Chem3obs,Chem4obs)
tau_1 <- mean(Chem1obs)-mean(Chemobs)
tau_2 <- mean(Chem2obs)-mean(Chemobs)
tau_3 <- mean(Chem3obs)-mean(Chemobs)
tau_4 <- mean(Chem4obs)-mean(Chemobs)

Pivoting Data to Estimate Beta_j

Chem5obs <- c(73,73,75,73)
Chem6obs <- c(68,67,68,71)
Chem7obs <- c(74,75,78,75)
Chem8obs <- c(71,72,73,75)
Chem9obs <- c(67,70,68,69)
Chemobs2 <- c(Chem5obs,Chem6obs,Chem7obs,Chem8obs,Chem9obs)

Estimating Beta_j

beta_1 <- mean(Chem5obs)-mean(Chemobs2)
beta_2 <- mean(Chem6obs)-mean(Chemobs2)
beta_3 <- mean(Chem7obs)-mean(Chemobs2)
beta_4 <- mean(Chem8obs)-mean(Chemobs2)
beta_5 <- mean(Chem9obs)-mean(Chemobs2)

Answers:

\(\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,

\(\hat{\beta_5}=\) -3.25.

Problem 4.22

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. Analyze the data from this experiment (use \(\alpha=0.05\)) and draw conclusions.

Setting Up Data

ProcessExperiment <- data.frame(
  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),
  Day = as.factor(c(1,2,3,4,5,
                    1,2,3,4,5,
                    1,2,3,4,5,
                    1,2,3,4,5,
                    1,2,3,4,5)),
  Batch = as.factor(c(1,1,1,1,1,
                      2,2,2,2,2,
                      3,3,3,3,3,
                      4,4,4,4,4,
                      5,5,5,5,5)),
  Ingredients = as.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")))

Running AOV

ProcessAOVmodel <- aov(Reaction_Time~Batch+Ingredients+Day,ProcessExperiment)
summary(ProcessAOVmodel)
##             Df Sum Sq Mean Sq F value   Pr(>F)    
## Batch        4  15.44    3.86   1.235 0.347618    
## Ingredients  4 141.44   35.36  11.309 0.000488 ***
## Day          4  12.24    3.06   0.979 0.455014    
## Residuals   12  37.52    3.13                     
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Conclusions

P-value for batch: \(0.348>0.05\). We fail to reject \(H_O\) and conclude that the batch number does not affect the reaction time.

P-value for day: \(0.455>0.05\). We fail to reject \(H_0\) and conclude that the day does not affect the reaction time.

P-value for ingredient: \(0.0005<0.05\). We reject \(H_0\) and conclude that the ingredient does affect the reaction time.