4.3
Question 4.3
Test Hypothesis
Ho: \(\mu_1 = \mu_2 = \mu_3 = \mu_4\) - Null Hypothesis
Ha: At least 1 differs - Alternative Hypothesis
\(\alpha\) = 0.05
Linear Effects
\(y_{ij} = \mu + \tau_i + \beta_i + \epsilon_{ij}\)
#install.packages("GAD")
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.
chemical<-c(rep(1,5), rep(2,5), rep(3,5), rep(4,5))
bolt<-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)
bolt<-as.fixed(bolt)
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
#summary(model)
From the result fo is 2.3761 with a corresponding p-value of 0.1211 is significantly greater than \(\alpha\) = 0.05. Therefore we fail to reject Ho that the means are equal, and conclude that none of the means are different. The treatment means chemical are the factor of interest here, bolt is recognized as blocks, which are nuisance and not the subjects we are studing on
Question 4.16
Linear Effects
\(y_{ij} = \mu + \tau_i + \beta_i + \epsilon_{ij}\)
#treatments chemical
t1<-c(73, 68, 74, 71, 67)
t2<-c(73, 67, 75, 72, 70)
t3<-c(75, 68, 78, 73, 68)
t4<-c(73, 71, 75, 75, 69)
#treatment mean
mt1<-mean(t1)
mt2<-mean(t2)
mt3<-mean(t3)
mt4<-mean(t4)
#blocks bolt
b1<-c(73,73,75,73)
b2<-c(68,67,68,71)
b3<-c(74,75,78,75)
b4<-c(71,72,73,75)
b5<-c(67,70,68,69)
#block mean
mb1<-mean(b1)
mb2<-mean(b2)
mb3<-mean(b3)
mb4<-mean(b4)
mb5<-mean(b5)
#grandmean
grandmean<-sum(obs)/20
grandmean
## [1] 71.75
#treatmentmean-grandmean
mt1-grandmean
## [1] -1.15
mt2-grandmean
## [1] -0.35
mt3-grandmean
## [1] 0.65
mt4-grandmean
## [1] 0.85
#blockmean-grandmean
mb1-grandmean
## [1] 1.75
mb2-grandmean
## [1] -3.25
mb3-grandmean
## [1] 3.75
mb4-grandmean
## [1] 1
mb5-grandmean
## [1] -3.25
\(\tau_1=-1.15 , \tau_2=-0.35 , \tau_3=0.65 , \tau_4=0.85 , \beta_1=1.75 , \beta_2=-3.25 , \beta_3=3.75 , \beta_4=1 , \beta_5=-3.25\)
\(\tau_1=-23/20 , \tau_2=-7/20 , \tau_3=13/20 , \tau_4=17/20 , \beta_1=35/20 , \beta_2=-65/20 , \beta_3=75/20 , \beta_4=20/20 , \beta_5=-65/20\)
Question 4.22
Test Hypothesis
Ho: \(\mu_1 = \mu_2 = \mu_3 = \mu_4\) - Null Hypothesis
Ha: At least 1 differs - Alternative Hypothesis
\(\alpha\) = 0.05
Linear Effects
\(y_{ij} = \mu + \tau_i + \beta_i + \alpha_k + \epsilon_{ij}\)
obs1 <- 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)
trt <- 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")
batch <- c(rep(1,5),rep(2,5),rep(3,5),rep(4,5),rep(5,5))
day <- c(rep(seq(1,5),5))
dat1 <- cbind(trt,batch,day)
dat1 <- as.data.frame(dat1)
dat1$obs1<-obs1
dat1$trt<-as.factor(dat1$trt)
dat1$batch<-as.factor(dat1$batch)
dat1$day<-as.factor(dat1$day)
str(dat1)
## 'data.frame': 25 obs. of 4 variables:
## $ trt : Factor w/ 5 levels "A","B","C","D",..: 1 2 4 3 5 3 5 1 4 2 ...
## $ 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 ...
## $ obs1 : num 8 7 1 7 3 11 2 7 3 8 ...
aov.model<-aov(obs1~trt+batch+day, data = dat1)
summary(aov.model)
## Df Sum Sq Mean Sq F value Pr(>F)
## trt 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
#plot(aov.model)
From the result fo is 11.309 with a corresponding p-value of 0.000488 is significantly less than \(\alpha\) = 0.05. Therefore we reject Ho that the means are equal, and conclude that the treatment means are different. The treatment means ingredients are the factor of interest here, batch and day are recognized as blocks, which are nuisance and not the subjects we are studing on
#**Question 4.3**
#install.packages("GAD")
library(GAD)
chemical<-c(rep(1,5), rep(2,5), rep(3,5), rep(4,5))
bolt<-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)
bolt<-as.fixed(bolt)
model<-lm(obs~chemical+bolt)
gad(model)
#**Question 4.16**
#treatments chemical
t1<-c(73, 68, 74, 71, 67)
t2<-c(73, 67, 75, 72, 70)
t3<-c(75, 68, 78, 73, 68)
t4<-c(73, 71, 75, 75, 69)
#treatment mean
mt1<-mean(t1)
mt2<-mean(t2)
mt3<-mean(t3)
mt4<-mean(t4)
#blocks bolt
b1<-c(73,73,75,73)
b2<-c(68,67,68,71)
b3<-c(74,75,78,75)
b4<-c(71,72,73,75)
b5<-c(67,70,68,69)
#block mean
mb1<-mean(b1)
mb2<-mean(b2)
mb3<-mean(b3)
mb4<-mean(b4)
mb5<-mean(b5)
#grandmean
grandmean<-sum(obs)/20
grandmean
#treatmentmean-grandmean
mt1-grandmean
mt2-grandmean
mt3-grandmean
mt4-grandmean
#blockmean-grandmean
mb1-grandmean
mb2-grandmean
mb3-grandmean
mb4-grandmean
mb5-grandmean
#**Question 4.22**
obs1 <- 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)
trt <- 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")
batch <- c(rep(1,5),rep(2,5),rep(3,5),rep(4,5),rep(5,5))
day <- c(rep(seq(1,5),5))
dat1 <- cbind(trt,batch,day)
dat1 <- as.data.frame(dat1)
dat1$obs1<-obs1
dat1$trt<-as.factor(dat1$trt)
dat1$batch<-as.factor(dat1$batch)
dat1$day<-as.factor(dat1$day)
str(dat1)
aov.model<-aov(obs1~trt+batch+day, data = dat1)
summary(aov.model)