#################### Question No: 4.3 ###################################
Hypothesis:
Null Hypothesis:Ho:μ1=μ2=μ3=μi Alternative Hypothesis: Ha : atleast one μi differs
As we know it has fixed effects hence we can write our hypothesis as,Null Hypothesis: Ho:τi=0 for all i Alternative Hypothesis: Ha : τi≠0 for some i. Linear Effects: yij=μ+τi+βj+ϵij Where μ is the grand mean, Where τi is the fixed effects for treatment i, Where βj is the block effect for j, Where ϵij is the random error.
Chemical <- c(rep(1,5),rep(2,5),rep(3,5),rep(4,5))
Bolts <- c(rep(seq(1,5),4))
OBS <- c(73,68,74,71,67,73,67,75,72,70,75,68,78,73,68,73,71,75,75,69)
library(GAD)
## Warning: package 'GAD' was built under R version 4.1.3
## Loading required package: matrixStats
## Warning: package 'matrixStats' was built under R version 4.1.3
## Loading required package: R.methodsS3
## Warning: package 'R.methodsS3' was built under R version 4.1.3
## R.methodsS3 v1.8.2 (2022-06-13 22:00:14 UTC) successfully loaded. See ?R.methodsS3 for help.
library(matrixStats)
library(R.methodsS3)
Chemical <- as.fixed(Chemical)
Bolts <- as.fixed(Bolts)
Model <- lm(OBS~Chemical+Bolts)
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
## Bolts 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
Comments: As we can see from anova test the p value as 0.1211 which is greater than 0.05 , hence we can claim that we fail to reject Null Hypothesis i.e we can say there is no difference among chemical on cloth even including nuisance variability of bolts.
############################## Question No:4.16 #############################
Calculating τi first for all i, As we know τi=μi−μ.
Tau_1 <- mean(OBS[1:5])-mean(OBS)
Tau_1
## [1] -1.15
Tau_2 <- mean(OBS[6:10])-mean(OBS)
Tau_2
## [1] -0.35
Tau_3 <- mean(OBS[11:15])-mean(OBS)
Tau_3
## [1] 0.65
Tau_4 <- mean(OBS[16:20])-mean(OBS)
Tau_4
## [1] 0.85
Answer: From above we get τ1= -1.15, τ2= -0.35, τ3= 0.65, τ4= 0.85.
Calculating βj first for all j As we know βj=μj−μ
beta_1 <- mean(c(73,73,75,73))-mean(OBS)
beta_1
## [1] 1.75
beta_2 <- mean(c(68,67,68,71))-mean(OBS)
beta_2
## [1] -3.25
beta_3 <- mean(c(74,75,78,75))-mean(OBS)
beta_3
## [1] 3.75
beta_4 <- mean(c(71,72,73,75))-mean(OBS)
beta_4
## [1] 1
beta_5 <- mean(c(67,70,68,69))-mean(OBS)
beta_5
## [1] -3.25
Answer: From above we get, β1= 1.75, β2= -3.25, β3= 3.75, β4= 1, β5= -3.25
####################### Question No: 4.22 ###############################
Hypothesis: Null Hypothesis: Ho:μ1=μ2=μ3=μi, Alternative Hypothesis: Ha : at least one μi differs
As we know it has fixed effects hence we can write our hypothesis as, Null Hypothesis: Ho:τi=0 for all i and Alternative Hypothesis: Ha : τi≠0 for some i,
Linear Effects Equation: Yijk=μ+τi+βj+γk+ϵijk Where μ is the grand mean, Where τi is the fixed effects for treatment i, Where βj is the block effect for j, Where γk is the block effect for k, Where ϵijk is the random error.
Day <- c(rep(1,5), rep(2,5), rep(3,5), rep(4,5), rep(5,5))
Batch <- c(rep(seq(1,5),5))
Ingredients <- c("A","C","B","D","E","B","E","A","C","D","D","A","C","E","B", "C","D","E","B","A","E","B","D","A","C")
OBS_2 <- c(8,11,4,6,4,7,2,9,8,2,1,7,10,6,3,7,3,1,6,8,3,8,5,10,8)
Day <-as.factor(Day)
Ingredients <-as.factor(Ingredients)
Batch <-as.factor(Batch)
Model_2 <- aov(OBS_2 ~ Batch+Day+Ingredients)
anova(Model_2)
## Analysis of Variance Table
##
## Response: OBS_2
## Df Sum Sq Mean Sq F value Pr(>F)
## Batch 4 15.44 3.860 1.2345 0.3476182
## Day 4 12.24 3.060 0.9787 0.4550143
## 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
Comment: As we can see from the anova test on the Latin Square model, it gave us a p value of 0.3476, which is greater than 0.05. This means that we can’t reject the Null Hypothesis and say that there is no difference between batches, since we know that days and ingredients can vary a lot. As we blocked them both.
And the factor that Day = 0.455 > 0.05 is significant when checked with a 95% confidence interval shows that blocking this was a good option.
Since the P value of the ingredients is 0.0004877, which is less than 0.05, this shows that the noise variability was not significant. But we still blocked it as it was a known source of nuisance. The main reason of blocking in first place was, as it was also a source of known nuisance variability So we conclude that the ingredients (A,B,C,D,E) have significant effect on the reaction time of the chemical process.