Required Packages:

library(GAD)
## Warning: package 'GAD' was built under R version 4.2.1
## Loading required package: matrixStats
## Warning: package 'matrixStats' was built under R version 4.2.1
## Loading required package: R.methodsS3
## R.methodsS3 v1.8.2 (2022-06-13 22:00:14 UTC) successfully loaded. See ?R.methodsS3 for help.

Answer to Question No- 4.3

Entering the data:

bolts <- c(73, 68, 74, 71, 67,
           73, 67, 75, 72, 70,
           75, 68, 78, 73, 68,
           73, 71, 75, 75, 69)

chemical <- c(rep(1,5),rep(2,5), rep(3,5), rep(4,5)) 
blocks <- c(rep(seq(1,5),4))
chemical <- as.fixed(chemical)
blocks <- as.fixed(blocks)

The model equation is given by:

y = μ + τ + β + ∈ Where the τ1, τ2, τ3, τ4 are the effects of each of the treatments on the grand mean (μ) and β1, β2, β3, β4, β5 are the block effects.

The hypothesis testing in terms of the effects parameters are as follows:

Null Hypothesis, Ho: For all treatments, the τ = 0

Alternative hypothesis, Ha: At least one of the τ0

We perform our generalized anova design:

model <- lm(bolts~chemical+blocks)
gad(model)
## Analysis of Variance Table
## 
## Response: bolts
##          Df Sum Sq Mean Sq F value    Pr(>F)    
## chemical  3  12.95   4.317  2.3761    0.1211    
## blocks    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

From the ANOVA table we observe that the p-value (0.112) is larger than our significance level (alpha = 0.05). Hence, we fail to reject the null hypothesis that for all treatments, the effect is equal to zero.

Hence, we conclude that the chemical treatments do not have any significant effect on the response variable.

Answer to Question No- 4.16

From Excel tables, we have the following screenshot:

From equation 4.26 in the 8th edition of Montgomery DAE, we have the following eqns:

μ = ȳ..

τi = ȳi. - ȳ..

βj = ȳ.j - ȳ..

Now, using the equations, we have the following parameter estimates:

τ1 = -1.15 τ2 = -0.35

τ3 = 0.65

τ4 = 0.85

β1 = 1.75 β2 = -3.25

β3 = 3.75

β4 = 1

β5 = -3.25

Answer to Question No- 4.22

Entering Data:

days <- c(rep(seq(1,5),5))
batch <- c(rep(1,5), rep(2,5), rep(3,5), rep(4,5), rep(5,5))
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)
ingredients <- 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")

days <- as.random(days)
batch <- as.fixed(batch)
ingredients <- as.fixed(ingredients)

Our model equation for the Latin square problem with two blocks are as follows:

y = μ + τ + β + α + ∈

Where the τ1, τ2, τ3, τ4, τ5 are the effects of each of the treatments on the grand mean (μ) and β1, β2, β3, β4, β5 are the block-1 effects (from days), and α1, α2, α3, α4, α5 are the effects from ingredients.

Now,

The hypothesis testing in terms of the effects parameters are as follows:

Null Hypothesis, Ho: For all treatments, the τ = 0

Alternative hypothesis, Ha: At least one of the τ0

Now, we run our GAD models with (1) batch+days (2) batch+ingredients (3) days+ingredients to check for any significance in the reaction time:

model_days_batch <- lm(obs~days+batch)
model_days_ingredients <- lm(obs~days+ingredients)
model_batch_ingredients <- lm(obs~batch+ingredients)
gad(model_batch_ingredients)
## Analysis of Variance Table
## 
## Response: obs
##             Df Sum Sq Mean Sq F value    Pr(>F)    
## batch        4  15.44    3.86  1.2412 0.3331444    
## ingredients  4 141.44   35.36 11.3698 0.0001456 ***
## Residual    16  49.76    3.11                      
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
gad(model_days_batch)
## Analysis of Variance Table
## 
## Response: obs
##          Df Sum Sq Mean Sq F value Pr(>F)
## days      4  12.24   3.060  0.2736 0.8907
## batch     4  15.44   3.860  0.3451 0.8435
## Residual 16 178.96  11.185
gad(model_days_ingredients)
## Analysis of Variance Table
## 
## Response: obs
##             Df Sum Sq Mean Sq F value    Pr(>F)    
## days         4  12.24    3.06  0.9245 0.4740920    
## ingredients  4 141.44   35.36 10.6828 0.0002069 ***
## Residual    16  52.96    3.31                      
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
model <- aov(obs~days+batch+ingredients)
anova(model)
## Analysis of Variance Table
## 
## Response: obs
##             Df Sum Sq Mean Sq F value    Pr(>F)    
## days         4  12.24   3.060  0.9787 0.4550143    
## batch        4  15.44   3.860  1.2345 0.3476182    
## ingredients  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

From the results we see that ingredients has a significant impact with p-value (<0.001) for all the models {(1) batch+days (2) batch+ingredients (3) days+ingredients (4) all together}. This is lower than our significance level of alpha = 0.05. Hence we reject the null hypothesis that the ingredients have no effects.

Hence, ingredients (A,B,C,D,E) have a significant effect on the reaction time period of the chemical process.

Complete Code Chunk:

#Answer to questio no-4.3

library(tidyverse)
install.packages("GAD")
library(GAD)

bolts <- c(73, 68, 74, 71, 67,
           73, 67, 75, 72, 70,
           75, 68, 78, 73, 68,
           73, 71, 75, 75, 69)

chemical <- c(rep(1,5),rep(2,5), rep(3,5), rep(4,5)) 
blocks <- c(rep(seq(1,5),4))


bolts
chemical
blocks

chemical <- as.fixed(chemical)
blocks <- as.fixed(blocks)

model <- lm(bolts~chemical+blocks)
gad(model)

#Answer to question no-4.16

#From excel table

#Answer to question no-4.22

days <- c(rep(seq(1,5),5))
batch <- c(rep(1,5), rep(2,5), rep(3,5), rep(4,5), rep(5,5))
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)
ingredients <- 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")

days <- as.random(days)
batch <- as.random(batch)
ingredients <- as.fixed(ingredients)

model_days_batch <- lm(obs~days+batch)
model_days_ingredients <- lm(obs~days+ingredients)
model_batch_ingredients <- lm(obs~batch+ingredients)
gad(model_batch_ingredients)
gad(model_days_batch)
gad(model_days_ingredients)
model <- aov(obs~days+batch+ingredients)
anova(model)