library(GAD)

Question 1.

Linear Equation: \(Y_{ij}=\mu + \tau_{i} +\beta_{j}+\epsilon_{ij}\)

Null Hypothesis: \(H_{0}:\mu_{1}=\mu_{2}=\mu_{3}=\mu_{4}\)

chemical is a factor (4 levels), bolts is observed (n=4).

chemical<-c(rep(1,4),rep(2,4),rep(3,4),rep(4,4))
chemical
##  [1] 1 1 1 1 2 2 2 2 3 3 3 3 4 4 4 4
obs<-c(73,68,74,71,
       73,67,75,72,
       75,68,78,73,
       73,71,75,75)
obs
##  [1] 73 68 74 71 73 67 75 72 75 68 78 73 73 71 75 75
chemical<-as.fixed(chemical)

#“as.fixed(chemical)” was used for blocking within the code.

model<-lm(obs~chemical)
gad(model)
## $anova
## Analysis of Variance Table
## 
## Response: obs
##           Df  Sum Sq Mean Sq F value Pr(>F)
## chemical   3  14.187  4.7292  0.4739 0.7062
## Residuals 12 119.750  9.9792

Comment:

P value is 0.7052>0.15 hence we fail to reject \(H_O\).

Question 2.

Linear Equation: \(Y_i = μ + \tau_{ij} + ε_i\)

Null Hypothesis: \(H_{0}:\mu_{1}=\mu_{2}=\mu_{3}=\mu_{4}\)

solution is a factor (4 levels), bolts is observed (n=4) and sequencing is in 4s.

solution<-c(rep(1,4),rep(2,4),rep(3,4),rep(4,4))
solution
##  [1] 1 1 1 1 2 2 2 2 3 3 3 3 4 4 4 4
bolts<-c(seq(1,4),seq(1,4),seq(1,4),seq(1,4))
bolts
##  [1] 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4
obs<-c(73,68,74,71,
       73,67,75,72,
       75,68,78,73,
       73,71,75,75)
obs
##  [1] 73 68 74 71 73 67 75 72 75 68 78 73 73 71 75 75
solution<-as.random(solution)
bolts<-as.random(bolts)
model<-lm(obs~solution+bolts)
gad(model)
## $anova
## Analysis of Variance Table
## 
## Response: obs
##           Df  Sum Sq Mean Sq F value    Pr(>F)    
## solution   3  14.187   4.729  2.7349 0.1057217    
## bolts      3 104.188  34.729 20.0843 0.0002515 ***
## Residuals  9  15.563   1.729                      
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

#“as.random(bolts)” was used for without blocking within the code.

Comment :

P value is 0.105<0.15 hence we reject \(H_O\).

Question 3.

In the first question, we used blocking on bolts and got P-value = 0.7062 > 0.15, hence we failed to reject the Null Hypothesis because there is no evidence of treatment differences. For the second question, we did not include blocking on bolts and the p-value = 0.105 < 0.15, so we rejected null hypothesis because there is evidence of treatment differences. This shows that when we used blocking , it helped account for nuisance variability. The main difference is that after blocking, residual mean square reduced significantly (from 9.979 in CRD to 1.729 in RCBD), which raised the treatment F and moved the p-value from far above 0.15 to below 0.15.

chemical<-c(rep(1,4),rep(2,4),rep(3,4),rep(4,4))
chemical
obs<-c(73,68,74,71,
       73,67,75,72,
       75,68,78,73,
       73,71,75,75)
obs
chemical<-as.fixed(chemical)
model<-lm(obs~chemical)
gad(model)
solution<-c(rep(1,4),rep(2,4),rep(3,4),rep(4,4))
solution
bolts<-c(seq(1,4),seq(1,4),seq(1,4),seq(1,4))
bolts
obs<-c(73,68,74,71,
       73,67,75,72,
       75,68,78,73,
       73,71,75,75)
obs
solution<-as.random(solution)
bolts<-as.random(bolts)
model<-lm(obs~solution+bolts)
gad(model)