MixingTech1<-c(3129,3000,2865,2890)
MixingTech2<-c(3200,3300,2975,3150)
MixingTech3<-c(2800,2900,2985,3050)
MixingTech4<-c(2600,2700,2600,2765)
dat <- data.frame(MixingTech1,MixingTech2,MixingTech3,MixingTech4)
library(tidyr)
dat<-pivot_longer(dat,c(MixingTech1,MixingTech2,MixingTech3,MixingTech4))
dat$name<-as.factor(dat$name)
3.7(c) Use the Fisher LSD method with α = 0.05 to make comparisons between pairs of means.
model_anov<-aov(value~name, data = dat)
summary(model_anov)
## Df Sum Sq Mean Sq F value Pr(>F)
## name 3 489740 163247 12.73 0.000489 ***
## Residuals 12 153908 12826
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
plot(model_anov)
## From Anova we reject null hypothes for above model becuase we got p value as 0.000489 which is far less than 0.05.
library(agricolae)
## Warning: package 'agricolae' was built under R version 4.1.3
model_LSD<-LSD.test(model_anov, "name", console = T)
##
## Study: model_anov ~ "name"
##
## LSD t Test for value
##
## Mean Square Error: 12825.69
##
## name, means and individual ( 95 %) CI
##
## value std r LCL UCL Min Max
## MixingTech1 2971.00 120.55704 4 2847.624 3094.376 2865 3129
## MixingTech2 3156.25 135.97641 4 3032.874 3279.626 2975 3300
## MixingTech3 2933.75 108.27242 4 2810.374 3057.126 2800 3050
## MixingTech4 2666.25 80.97067 4 2542.874 2789.626 2600 2765
##
## Alpha: 0.05 ; DF Error: 12
## Critical Value of t: 2.178813
##
## least Significant Difference: 174.4798
##
## Treatments with the same letter are not significantly different.
##
## value groups
## MixingTech2 3156.25 a
## MixingTech1 2971.00 b
## MixingTech3 2933.75 b
## MixingTech4 2666.25 c
model_LSD$groups
## value groups
## MixingTech2 3156.25 a
## MixingTech1 2971.00 b
## MixingTech3 2933.75 b
## MixingTech4 2666.25 c
## MixingTech 1 and 3 has same value it means Mixing Tech 1 and Mixing Tech 3 has same means but The Remaining techniques that have different characters in the groups column are significantly different. So MixingTechniques pairs [(2,1),(2,3),(2,4),(1,4),(3,4)] are significantly different in mean.
plot(model_LSD)
From Anova we reject null hypothes for above model becuase we got p
value as 0.000489 which is far less than 0.05.
Hypothesis:
Null Hypothesis (Ho): μ1 = μ2, μ1 = μ3, μ1 = μ4, μ2 = μ3, μ2 = μ4, μ3 = μ4.
Alternative Hypothesis (Ha): one of μi differ.
Concluding from the LSD test and plots.
μ1 = μ3 - we fail to reject Null Hypothesis (Ho).
μ1 ≠ μ2, μ1 ≠ μ4, μ2 ≠ μ3, μ2 ≠ μ4, μ3 ≠ μ4 - we reject Null Hypothesis (Ho).
3.7(e) Plot the residuals versus the predicted tensile strength. Comment on the plot. ### Plot of Residuals vs Tensile strength.
residuals <- resid(model_anov)
qqplot(dat$value, residuals, main = "Residuals vs Tensile strength", xlab = "Tensile Strength", ylab = "Residuals")
qqline(dat$value, residuals)
## Warning in if (datax) {: the condition has length > 1 and only the first element
## will be used
Comments: The plot has the residuals values ranging form -150 to 150, but we could see the points are barely on the line.
3.7(d) Construct a normal probability plot of the residuals. What conclusion would you draw about the validity of the normality assumption?
3.7(f) Prepare a scatter plot of the results to aid the interpretation of the results of this experiment.
plot(model_anov)
Comments: The normal probability plot of the residuals is normally distributed as we could see, this give us the we could take strong normality assumption.
plot(dat$value, ylab = "Tensile Strength")
### Entering the sample data an formation of data frame.....
MixingTech1<-c(3129,3000,2865,2890)
MixingTech2<-c(3200,3300,2975,3150)
MixingTech3<-c(2800,2900,2985,3050)
MixingTech4<-c(2600,2700,2600,2765)
dat <- data.frame(MixingTech1,MixingTech2,MixingTech3,MixingTech4)
library(tidyr)
dat<-pivot_longer(dat,c(MixingTech1,MixingTech2,MixingTech3,MixingTech4))
dat$name<-as.factor(dat$name)
### Least Significant Difference calculation.
model_anov<-aov(value~name, data = dat)
summary(model_anov)
plot(model_anov)
## From Anova we reject null hypothes for above model becuase we got p value as 0.000489 which is far less than 0.05.
library(agricolae)
model_LSD<-LSD.test(model_anov, "name", console = T)
model_LSD$groups
## MixingTech 1 and 3 has same value it means Mixing Tech 1 and Mixing Tech 3 has same means but The Remaining techniques that have different characters in the groups column are significantly different. So MixingTechniques pairs [(2,1),(2,3),(2,4),(1,4),(3,4)] are significantly different in mean.
plot(model_LSD)
### Plot of Residuals vs Tensile strength.
residuals <- resid(model_anov)
qqplot(dat$value, residuals, main = "Residuals vs Tensile strength", xlab = "Tensile Strength", ylab = "Residuals")
qqline(dat$value, residuals)
### Plots of results.
plot(model_anov)
### Scatter plot of all Tensile Strength values.
plot(dat$value, ylab = "Tensile Strength")
Obs<-c(7, 7, 15, 11, 9, 12, 17, 12, 18, 18, 14, 19, 19, 18, 18, 19, 25, 22, 19, 23, 7, 10, 11, 15, 11)
Cot_Wgt_per<-c(rep(15,5),rep(20,5),rep(25,5),rep(30,5),rep(35,5))
Cot_Wgt_per<-as.factor(Cot_Wgt_per)
dat2<-cbind.data.frame(Obs, Cot_Wgt_per)
3.10(b) Use the Fisher LSD method to make comparisons between the pairs of means. What conclusions can you draw?
model_anov1<-aov(Obs~Cot_Wgt_per , data = dat2)
summary(model_anov1)
## Df Sum Sq Mean Sq F value Pr(>F)
## Cot_Wgt_per 4 475.8 118.94 14.76 9.13e-06 ***
## Residuals 20 161.2 8.06
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# from anova model we got p value as 9.13e-06 it is far less than 0.05 so we can reject null hypothesiss
model_LSD1<-LSD.test(model_anov1, "Cot_Wgt_per", console = T)
##
## Study: model_anov1 ~ "Cot_Wgt_per"
##
## LSD t Test for Obs
##
## Mean Square Error: 8.06
##
## Cot_Wgt_per, means and individual ( 95 %) CI
##
## Obs std r LCL UCL Min Max
## 15 9.8 3.346640 5 7.151566 12.44843 7 15
## 20 15.4 3.130495 5 12.751566 18.04843 12 18
## 25 17.6 2.073644 5 14.951566 20.24843 14 19
## 30 21.6 2.607681 5 18.951566 24.24843 19 25
## 35 10.8 2.863564 5 8.151566 13.44843 7 15
##
## Alpha: 0.05 ; DF Error: 20
## Critical Value of t: 2.085963
##
## least Significant Difference: 3.745452
##
## Treatments with the same letter are not significantly different.
##
## Obs groups
## 30 21.6 a
## 25 17.6 b
## 20 15.4 b
## 35 10.8 c
## 15 9.8 c
model_LSD1$groups
## Obs groups
## 30 21.6 a
## 25 17.6 b
## 20 15.4 b
## 35 10.8 c
## 15 9.8 c
## From Model_LSD$groups table. we can say cotton weight percentage of (25,20) (35,15) pairs has almost same mean but pairs with percentage (30,25),(30,35),(30,15),(25,35),(25,15),(20,35),(20,15) have significant mean difference so totally we can reject null hypothesis
plot(model_LSD1)
From
Model_LSD$groups table. we can say cotton weight percentage of (25,20)
(35,15) pairs has almost same mean but pairs with percentage
(30,25),(30,35),(30,15),(25,35),(25,15),(20,35),(20,15) have significant
mean difference so totally we can reject null hypothesis.
Hypothesis:
Null Hypothesis (Ho): μ1 = μ2, μ1 = μ3, μ1 = μ4, μ1 = μ5, μ2 = μ3, μ2 = μ4, μ2 = μ5, μ3 = μ4, μ3 = μ5, μ4 = μ5.
Alternative Hypothesis (Ha): one of μi differ.
Concluding from the LSD test and plots.
μ1 = μ5, μ2 = μ3 - we fail to reject Null Hypothesis (Ho).
μ1 ≠ μ2, μ1 ≠ μ3, μ1 ≠ μ4, μ2 ≠ μ4, μ2 ≠ μ5, μ3 ≠ μ4, μ3 ≠ μ5, μ4 ≠ μ5 - we reject Null Hypothesis (Ho).
where:
μ1 = Mean of 15% Cotton Weight.
μ2 = Mean of 20% Cotton Weight.
μ3 = Mean of 25% Cotton Weight.
μ4 = Mean of 30% Cotton Weight.
μ5 = Mean of 35% Cotton Weight.
3.10(c) Analyze the residuals from this experiment and comment on model adequacy.
plot(model_anov1)
Comments: The model seem inadequate, because of the shorter Residuals range of the few samples (25 and 20) and scattered arrangement.
# Q3.10
# Entering the sample data an formation of data frame.....
Obs<-c(7, 7, 15, 11, 9, 12, 17, 12, 18, 18, 14, 19, 19, 18, 18, 19, 25, 22, 19, 23, 7, 10, 11, 15, 11)
Cot_Wgt_per<-c(rep(15,5),rep(20,5),rep(25,5),rep(30,5),rep(35,5))
Cot_Wgt_per<-as.factor(Cot_Wgt_per)
dat2<-cbind.data.frame(Obs, Cot_Wgt_per)
# LSD test.....
model_anov1<-aov(Obs~Cot_Wgt_per , data = dat2)
model_LSD1<-LSD.test(model_anov1, "Cot_Wgt_per", console = T)
plot(model_LSD1)
# ANOVA and Residuals....
plot(model_anov1)
μ1 = μ3 = 50, μ2 = μ4 = 60.
power = 0.9, α = 0.05.
library(pwr)
## Warning: package 'pwr' was built under R version 4.1.3
##d= effect size = Means difference/ σ(standard deviation),d = 10 / 5 = 2,
##f = d
pwr.anova.test(k = 4, n = NULL, f = 2, sig.level = 0.05, power = 0.9)
##
## Balanced one-way analysis of variance power calculation
##
## k = 4
## n = 2.170367
## f = 2
## sig.level = 0.05
## power = 0.9
##
## NOTE: n is number in each group
Number of samples to choose from the given values is n = 2.17 ~ 3. So 3 observations should be taken from each group.
μ1 = μ3 = 50, μ2 = μ4 = 60.
power = 0.9, α = 0.05.
3.45(a) How would your answer change if a reasonable estimate of the experimental error variance were σ^2 = 36?
pwr.anova.test(k = 4, n = NULL, f = sqrt(((60-50)^2)/36), sig.level = 0.05, power = 0.9)
##
## Balanced one-way analysis of variance power calculation
##
## k = 4
## n = 2.518782
## f = 1.666667
## sig.level = 0.05
## power = 0.9
##
## NOTE: n is number in each group
Number of samples to choose from the given values is n = 2.518 ~ 3.
3.45(b) How would your answer change if a reasonable estimate of the experimental error variance were σ^2 = 49?
pwr.anova.test(k = 4, n = NULL, f = sqrt(((60-50)^2)/49), sig.level = 0.05, power = 0.9)
##
## Balanced one-way analysis of variance power calculation
##
## k = 4
## n = 2.939789
## f = 1.428571
## sig.level = 0.05
## power = 0.9
##
## NOTE: n is number in each group
Number of samples to choose from the given values is n = 2.939 ~ 3.
3.45(c) Can you draw any conclusions about the sensitivity of your answer in this particular situation about how your estimate of σ affects the decision about sample size?
Ans: From the analysis we could see that by increasing the values of σ the number of samples required is increasing with increase in σ and we are getting closer to the rounded-off value for the given values of μ’s, power, and α, and effect size will also go down.
3.45(d) Can you make any recommendations about how we should use this general approach to choosing n in practice?
Ans: The increase in the σ is increasing the number of samples and decreasing the effect size. we could use this to get the close accurate results.
# Q3.44, Q3.45.
# Given....
# μ1 = μ3 = 50, μ2 = μ4 = 60.
# power = 0.9, α = 0.05.
library(pwr)
# σ^2 = 25.
pwr.anova.test(k = 4, n = NULL, f = sqrt(((60-50)^2)/25), sig.level = 0.05, power = 0.9)
# σ^2 = 36.
pwr.anova.test(k = 4, n = NULL, f = sqrt(((60-50)^2)/36), sig.level = 0.05, power = 0.9)
# σ^2 = 49.
pwr.anova.test(k = 4, n = NULL, f = sqrt(((60-50)^2)/49), sig.level = 0.05, power = 0.9)