Probelm 4.3

library(GAD)
## Loading required package: matrixStats
## Loading required package: R.methodsS3
## R.methodsS3 v1.8.1 (2020-08-26 16:20:06 UTC) successfully loaded. See ?R.methodsS3 for help.
obs<-c(73,68,74,71,67,73,67,75,72,70,75,68,78,73,68,73,71,75,75,69)
bolt<-c(rep(seq(1,5),4))
chemical<-c(rep(1,5),rep(2,5),rep(3,5),rep(4,5))
bolt<-as.fixed(bolt)
chemical<-as.fixed(chemical)
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

Null Hypothesis : \(H_o : \tau_i = 0\)

Alternative Hypothesis : \(H_a : \tau_i \neq 0\) for some i

As p value is more than α= 0.05, we conclude that we fail to reject the null hypothesis

Probelm 4.16

c1<-c(73,68,74,71,67)
c2<-c(73,67,75,72,70)
c3<-c(75,68,78,73,68)
c4<-c(73,71,75,75,69)
a<-c(c1,c2,c3,c4)
mean(a)
## [1] 71.75
mean(c1)
## [1] 70.6
mean(c2)
## [1] 71.4
mean(c3)
## [1] 72.4
mean(c4)
## [1] 72.6
tau1<-mean(c1)-mean(a)
tau1
## [1] -1.15
tau2<-mean(c2)-mean(a)
tau2
## [1] -0.35
tau3<-mean(c3)-mean(a)
tau3
## [1] 0.65
tau4<-mean(c4)-mean(a)
tau4
## [1] 0.85
bolt1<-c(73,73,75,73)
bolt2<-c(68,67,68,71)
bolt3<-c(74,75,78,75)
bolt4<-c(71,72,73,75)
bolt5<-c(67,70,68,69)
bolt<-c(bolt1,bolt2,bolt3,bolt4,bolt5)
mean(bolt)
## [1] 71.75
b1<-mean(bolt1)-mean(bolt)
b1
## [1] 1.75
b2<-mean(bolt2)-mean(bolt)
b2
## [1] -3.25
b3<-mean(bolt3)-mean(bolt)
b3
## [1] 3.75
b4<-mean(bolt4)-mean(bolt)
b4
## [1] 1
b5<-mean(bolt5)-mean(bolt)
b5
## [1] -3.25

tau= mui(Chemical)-grand mean

beta= mui(bolt)-grand mean

Probelm 4.22

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)
Batch <- 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)
Day <- c(rep(seq(1,5),5))
Ingredient <- c(1,2,4,3,5,3,5,1,4,2,2,1,3,5,4,4,3,5,2,1,5,4,2,1,3)
Batch <- as.factor(Batch)
Day <- as.factor(Day)
Ingredient <- as.factor(Ingredient)
Data <- data.frame(Obs, Batch, Day, Ingredient)
str(Data)
## 'data.frame':    25 obs. of  4 variables:
##  $ Obs       : num  8 7 1 7 3 11 2 7 3 8 ...
##  $ 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 "1","2","3","4",..: 1 2 4 3 5 3 5 1 4 2 ...
aov.model<-aov(Obs~Ingredient+Batch+Day,data=Data)
summary(aov.model)
##             Df Sum Sq Mean Sq F value   Pr(>F)    
## Ingredient   4 141.44   35.36  11.309 0.000488 ***
## Batch        4  15.44    3.86   1.235 0.347618    
## 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

Null hypothesis Ho = τi=0

Alternate hypothesis Ha = τi≠0

We can say that it is a valid latin square because in each column or row one ingredient occurs only once and there’s no repetition thus it’s valid and it’s orthogonal.

As the p-value for the ANOVA analysis w.r.t. ingredients is smaller than 0.05, we reject the null hypothesis and thus we conclude that there’s a significant effect of ingredients on the mean reaction times of chemical processes.