A chemist wishes to test the effect of four chemical agents on the strength of a particular type of cloth. Because there might be variability from one bolt to another, the chemist decides to use a randomized block design, with the bolts of cloth considered as blocks. She selects five bolts and applies all four chemicals in random order to each bolt. The resulting tensile strengths follow. Analyze the data from this experiment (use ( $ 0.05) and draw appropriate conclusions.
Null Hypothesis: \[\tau _{i}=0\forall "i"\]
Alternative hypothesis: \[\tau _{i}\neq 0\exists "i"\]
Equation: \[y_{ij}= \mu + \tau _{i}+\beta _{j}+\epsilon _{ij}\]
Where:
\(y_{ij}= Observation\)
\(\epsilon _{ij}=Random error term\)
\(\tau _{i}= Effect of the ith Chemical treatment Agent\)
\(\beta _{j}= jth block effect of the agent used\)
\(\mu = Grand Mean\)
Fixing the data:
chemical1 <- c(73, 68, 74, 71, 67)
chemical2 <- c(73, 67, 75, 72, 70)
chemical3 <- c(75, 68, 78, 73, 68)
chemical4 <- c(73, 71, 75, 75, 69)
dat<- data.frame(chemical1,chemical2,chemical3,chemical4)
dat <- stack(dat)
colnames(dat) <- c('Number','Type')
library(GAD)
## Loading required package: matrixStats
## Loading required package: R.methodsS3
## R.methodsS3 v1.8.2 (2022-06-13 22:00:14 UTC) successfully loaded. See ?R.methodsS3 for help.
dat$Type <- as.fixed(dat$Type)
dat$Bolt <- c(rep(seq(1,5),4))
dat$Bolt <- as.fixed(dat$Bolt)
we are condisering a randomized block design. The bolt type is blocked since we consider the bolt type to be a main source of nuisance variability.
model1<- lm(Number~Type+Bolt,dat)
gad(model1)
## Analysis of Variance Table
##
## Response: Number
## Df Sum Sq Mean Sq F value Pr(>F)
## Type 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
With a P value (0.1211) greater than 0.05, we do not reject the null hypothesis.
Conclusion: The chemical agent do not have a significant effect on the mean strength.
Assuming that chemical types and bolts are fixed, estimate the model parameters tau and Beta in Problem 4.3.
chem_1<- c(73,68,74,71,67)
chem_2<- c(73,67,75,72,70)
chem_3<- c(75,68,78,73,68)
chem_4<- c(73,71,75,75,69)
chems<- c(chem_1,chem_2,chem_3,chem_4)
str(chems)
## num [1:20] 73 68 74 71 67 73 67 75 72 70 ...
tau1 <- mean(chem_1)-mean(chems)
tau2 <- mean(chem_2)-mean(chems)
tau3 <- mean(chem_3)-mean(chems)
tau4 <- mean(chem_4)-mean(chems)
Getting the result from the global environment
tau1=-1.15
tau2=-0.35
tau3=0.65
tau4=0.85
Now data for Beta_j
Chem_5 <- c(73,73,75,73)
Chem_6 <- c(68,67,68,71)
Chem_7 <- c(74,75,78,75)
Chem_8 <- c(71,72,73,75)
Chem_9 <- c(67,70,68,69)
Chem_10<- c(Chem_5,Chem_6,Chem_7,Chem_8,Chem_9)
Getting the answers for Beta_j
beta1<- mean(Chem_5)-mean(Chem_10)
beta2<- mean(Chem_6)-mean(Chem_10)
beta3<- mean(Chem_7)-mean(Chem_10)
beta4<- mean(Chem_8)-mean(Chem_10)
beta5<- mean(Chem_9)-mean(Chem_10)
beta 1=1.75
beta 2=-3.25
beta3=3.75
beta4=1
beta5=-3.25
The effect of five different ingredients (A, B, C, D, E) on the reaction time of a chemical process is being studied. Each batch of new material is only large enough to permit five runs to be made. Furthermore, each run requires approximately 1.5 hours, so only five runs can be made in one day. The experimenter decides to run the experiment as a Latin square so that day and batch effects may be systematically controlled. She obtains the data that follow. Analyze the data from this experiment use α�= 0.05 and draw conclusions.
Inputting the data
library(GAD)
batchs<- c(rep(1,5),rep(2,5),rep(3,5),rep(4,5),rep(5,5))
Days<- c(rep(seq(1,5),5))
ingred<- 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")
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)
dat<- cbind(batchs,Days,ingred,obs)
dat<- as.data.frame(dat)
dat$batchs<- as.fixed(dat$batchs)
dat$Days<- as.fixed(dat$Days)
dat$ingred <- as.fixed(dat$ingred)
Defining our null and alternative hypothesis:
Null Hypothesis:
\[ H_{0}: \tau _{i}=0\forall "i" \]
Alternative hypothesis: \[H_{a}: \tau _{i}\neq 0 \exists "i"\]
Testing for equation: \(y_{ij}= \mu + \tau _{i}+\beta _{j}+\alpha _{k}+\epsilon _{ij}\)
Given: \(y_{ij}\) = Observation
\(\mu\)= Grand Mean
\(\tau _{i}\)= the ith effect of the treatment on ingredient
\(\beta _{j}\)=Jth effect on the given batch
\(\alpha _{k}\)= effect of the block
\(\epsilon _{ij}\)= Random error
model1<- lm(dat$obs~dat$batchs+dat$Days+dat$ingred,data = dat)
anova(model1)
## Analysis of Variance Table
##
## Response: dat$obs
## Df Sum Sq Mean Sq F value Pr(>F)
## dat$batchs 4 15.44 3.860 1.2345 0.3476182
## dat$Days 4 12.24 3.060 0.9787 0.4550143
## dat$ingred 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
#Question 4.3
#loading the data
chemical1 <- c(73, 68, 74, 71, 67)
chemical2 <- c(73, 67, 75, 72, 70)
chemical3 <- c(75, 68, 78, 73, 68)
chemical4 <- c(73, 71, 75, 75, 69)
dat<- data.frame(chemical1,chemical2,chemical3,chemical4)
dat <- stack(dat)
colnames(dat) <- c('Number','Type')
library(GAD)
dat$Type <- as.fixed(dat$Type)
dat$Bolt <- c(rep(seq(1,5),4))
dat$Bolt <- as.fixed(dat$Bolt)
model1<- lm(Number~Type+Bolt,dat)
gad(model1)
#Question 4.16
chem_1<- c(73,68,74,71,67)
chem_2<- c(73,67,75,72,70)
chem_3<- c(75,68,78,73,68)
chem_4<- c(73,71,75,75,69)
chems<- c(chem_1,chem_2,chem_3,chem_4)
str(chems)
tau2 <- mean(chem_2)-mean(chems)
tau3 <- mean(chem_3)-mean(chems)
tau4 <- mean(chem_4)-mean(chems)
Chem_5 <- c(73,73,75,73)
Chem_6 <- c(68,67,68,71)
Chem_7 <- c(74,75,78,75)
Chem_8 <- c(71,72,73,75)
Chem_9 <- c(67,70,68,69)
Chem_10<- c(Chem_5,Chem_6,Chem_7,Chem_8,Chem_9)
beta1<- mean(Chem_5)-mean(Chem_10)
beta2<- mean(Chem_6)-mean(Chem_10)
beta3<- mean(Chem_7)-mean(Chem_10)
beta4<- mean(Chem_8)-mean(Chem_10)
beta5<- mean(Chem_9)-mean(Chem_10)
#3Question 4.22
#Loading the data
library(GAD)
batchs<- c(rep(1,5),rep(2,5),rep(3,5),rep(4,5),rep(5,5))
Days<- c(rep(seq(1,5),5))
ingred<- 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")
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)
dat<- cbind(batchs,Days,ingred,obs)
dat<- as.data.frame(dat)
dat$batchs<- as.fixed(dat$batchs)
dat$Days<- as.fixed(dat$Days)
dat$ingred <- as.fixed(dat$ingred)
model1<- lm(dat$obs~dat$batchs+dat$Days+dat$ingred,data = dat)
anova(model1)