Problem 1:

\(\overline{y_{ij}}=\mu_{i}+\beta{j}+\epsilon_{ij}\)

\(\overline{y_{ij}}=\mu+\tau_{i}+\beta{j}+\epsilon_{ij}\)

Corresponding to:

\(\tau_{i}=0\) null hypothesis: \(H_0: \mu_{1}=\mu_{2}=\cdots =\mu_{i}=\mu\)

\(\tau_{i}\ne 0\) alternative hypothesis: \(H_1:\) at least one \(\mu_{i}\) differs

lm: linear model \(\tau_{i}\):fixed effect error

library(GAD)
## 载入需要的程辑包:matrixStats
## 载入需要的程辑包: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)
obs
##  [1] 73 68 74 71 67 73 67 75 72 70 75 68 78 73 68 73 71 75 75 69
chem <-c(rep(1,5),rep(2,5),rep(3,5),rep(4,5)) 
bolt <- rep(seq(1,5),4)
chem<-as.fixed(chem)
bolt<-as.fixed(bolt)
model<-lm(obs~chem+bolt)
gad(model)
## Analysis of Variance Table
## 
## Response: obs
##          Df Sum Sq Mean Sq F value    Pr(>F)    
## chem      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

Ans: P-value=0.1211 <0.15, so we reject null hypothesis (i.e., means are not equal).

————————————————————————————————

Problem 2:

\(\overline{y_{ij}}=\mu_{i}+\epsilon_{ij}\)

\(\overline{y_{ij}}=\mu+\tau_{i}+\epsilon_{ij}\)

Corresponding to:

\(\tau_{i}=0\) null hypothesis: \(H_0: \mu_{1}=\mu_{2}=\cdots =\mu_{i}=\mu\)

\(\tau_{i}\ne 0\) alternative hypothesis: \(H_1:\) at least one \(\mu_{i}\) differs

model2<-lm(obs~chem)
gad(model2)
## Analysis of Variance Table
## 
## Response: obs
##          Df Sum Sq Mean Sq F value Pr(>F)
## chem      3  12.95  4.3167  0.3863 0.7644
## Residual 16 178.80 11.1750

Ans: p-value=0.7644 > 0.15, so we do not reject null hypothesis (i.e., means are equal).

Another way in ANOVA:

r1 <- c(73,68,74,71,67)
r2 <- c(73,67,75,72,70)
r3 <- c(75,68,78,73,68)
r4 <- c(73,71,75,75,69)
obs <- c(r1,r2,r3,r4)

dat1 <- cbind(obs,chem)
str(dat1)
##  num [1:20, 1:2] 73 68 74 71 67 73 67 75 72 70 ...
##  - attr(*, "dimnames")=List of 2
##   ..$ : NULL
##   ..$ : chr [1:2] "obs" "chem"
dat1 <- as.data.frame(dat1)
str(dat1)
## 'data.frame':    20 obs. of  2 variables:
##  $ obs : num  73 68 74 71 67 73 67 75 72 70 ...
##  $ chem: num  1 1 1 1 1 2 2 2 2 2 ...
dat1$chem <- as.factor(dat1$chem)
str(dat1)
## 'data.frame':    20 obs. of  2 variables:
##  $ obs : num  73 68 74 71 67 73 67 75 72 70 ...
##  $ chem: Factor w/ 4 levels "1","2","3","4": 1 1 1 1 1 2 2 2 2 2 ...
aov.model<-aov(obs~chem, data = dat1)
summary(aov.model)
##             Df Sum Sq Mean Sq F value Pr(>F)
## chem         3  12.95   4.317   0.386  0.764
## Residuals   16 178.80  11.175
plot(aov.model)

boxplot(obs~chem,xlab="type/method",ylab="observation",main="Boxplot of Observations")

If we do it in ANOVA, results are the same at p-value=0.764.

————————————————————————————————

Problem 3:

Ans: P-value=0.1211 if we block the bolt compared to p-value=0.7644 if we do not block the bolt. If we block the bolt, it will introduce the niusance variability, MSE will significantly drop, f increases and p-value decreases in this case. Thus, bolt of cloth represents a significant amount of nuisance variability. This will affect our final conclusion significantly.

————————————————————————————————

R code display:

library(GAD)
obs<- c(73,68,74,71,67,73,67,75,72,70,75,68,78,73,68,73,71,75,75,69)
obs
chem <-c(rep(1,5),rep(2,5),rep(3,5),rep(4,5)) 
bolt <- rep(seq(1,5),4)
chem<-as.fixed(chem)
bolt<-as.fixed(bolt)
model<-lm(obs~chem+bolt)
gad
model2<-lm(obs~chem)
gad(model2)