Question 4.3
#Question 4.3
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.
#Reading the data
#Null Hypothesis, Ho: For all treatments, the τ = 0
#Alternative hypothesis, Ha: At least one of the τ ≠ 0
Bolt <- c(73, 68, 74, 71, 67,
73, 67, 75, 72, 70,
75, 68, 78, 73, 68,
73, 71, 75, 75, 69)
chemical <- c(rep(1,5),rep(2,5), rep(3,5), rep(4,5))
Blocks <- c(rep(seq(1,5),4))
chemical <- as.fixed(chemical)
Blocks <- as.fixed(Blocks)
#The model equation is given by:
#Yij = μ + τi + βj + ∈ij
#Where τ1, τ2, τ3, τ4 = effects of the treatments
#μ = grand mean and
#β1, β2, β3, β4, β5 = block effects.
#Perform ANOVA
model <- lm(Bolt~chemical+Blocks)
gad(model)
## Analysis of Variance Table
##
## Response: Bolt
## Df Sum Sq Mean Sq F value Pr(>F)
## chemical 3 12.95 4.317 2.3761 0.1211
## Blocks 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
#Therefore by the ANOVA P value is 0.1211 which is greater than alpha 0.05.Hence we fail to reject the null hypothesis
#By this we can say that treatments do not have any significant effect
Question 4.16
#Question 4.16
#From the given data
#mean of treatment1 70.6
#mean of treatment2 71.4
#mean of teatment3 72.4
#mean of treatment4 72.6
#Grand mean 71.75
#mean of block1 73.5
#mean of block2 68.5
#mean of block3 75.5
#mean of block4 72.75
#mean of block5 68.5
#Calculating Ti
#t1=Y1..-mu=-1.15
#t2=Y2..-mu=-0.35
#t3=Y3..-mu=0.65
#t4=Y4..-mu=0.85
#Calculating betaj
#b1=Y..1-mu=1.75
#b2=Y..2-Mu=-3.25
#b3=Y..3-mu=3.75
#b4=Y..4-mu=1
#b5=Y..5-mu=-3.25
Question 4.22
#Reading the given data
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)
batch <- c(rep(1,5), rep(2,5), rep(3,5), rep(4,5), rep(5,5))
days <- c(rep(seq(1,5),5))
ingredients <- 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")
days <- as.factor(days)
batch <- as.factor(batch)
ingedients <- as.factor(ingredients)
Data <- data.frame(obs,batch,days,ingredients)
str(Data)
## 'data.frame': 25 obs. of 4 variables:
## $ obs : num 8 7 1 7 3 11 2 7 3 8 ...
## $ batch : Factor w/ 5 levels "1","2","3","4",..: 1 1 1 1 1 2 2 2 2 2 ...
## $ days : Factor w/ 5 levels "1","2","3","4",..: 1 2 3 4 5 1 2 3 4 5 ...
## $ ingredients: chr "A" "B" "D" "C" ...
#Linear model effects equation can be given as
#Yi,j,k = mu+Ti+Bj+ak+Ei,j,k
#Ti is the ingredient effect
#NUll hypothesis:H0:Ti=0
#Alternate Hypothesis:HA:Ti NE 0
aov.model <- aov(obs~ingredients+batch+days,data=Data)
summary(aov.model)
## Df Sum Sq Mean Sq F value Pr(>F)
## ingredients 4 141.44 35.36 11.309 0.000488 ***
## batch 4 15.44 3.86 1.235 0.347618
## days 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
#Therefore P value is 0.000488 which smaller than alpha 0.05.Hence, we reject the null Hypothesis
#We conclude that there is significant effect of ingredients on mean reaction times of chemical processes.