# Problem: 3.7
library(agricolae)
Mix_Tech <- c("1","1","1","1","2","2","2","2","3","3","3","3","4","4","4","4")
Ten_Str <- c(3129,3000,2865,2890,3200,3300,2975,3150,2800,2900,2985,3050,2600,2700,2600,2765)
dat <- data.frame(Mix_Tech,Ten_Str)
dat$Ten_Str <- as.numeric(dat$Ten_Str)
dat$Mix_Tech <- as.factor(Mix_Tech)
str(dat)
## 'data.frame':    16 obs. of  2 variables:
##  $ Mix_Tech: Factor w/ 4 levels "1","2","3","4": 1 1 1 1 2 2 2 2 3 3 ...
##  $ Ten_Str : num  3129 3000 2865 2890 3200 ...
model <- aov(Ten_Str~Mix_Tech,data=dat)
summary(model)
##             Df Sum Sq Mean Sq F value   Pr(>F)    
## Mix_Tech     3 489740  163247   12.73 0.000489 ***
## Residuals   12 153908   12826                     
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
LSD.test(model,"Mix_Tech",console = TRUE)
## 
## Study: model ~ "Mix_Tech"
## 
## LSD t Test for Ten_Str 
## 
## Mean Square Error:  12825.69 
## 
## Mix_Tech,  means and individual ( 95 %) CI
## 
##   Ten_Str       std r      LCL      UCL  Min  Max
## 1 2971.00 120.55704 4 2847.624 3094.376 2865 3129
## 2 3156.25 135.97641 4 3032.874 3279.626 2975 3300
## 3 2933.75 108.27242 4 2810.374 3057.126 2800 3050
## 4 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.
## 
##   Ten_Str groups
## 2 3156.25      a
## 1 2971.00      b
## 3 2933.75      b
## 4 2666.25      c
# Answer to the problem: 3.7(c)
# Hypothesis: 
# Null Hypothesis (Ho): u1 = u2, u1 = u3, u1 = u4, u2 = u3, u2 = u4, u3 = u4.
# Alternative Hypothesis (Ha): at least one of the mean (ui) differs.
# µ1 and µ3 are similar ,
# µ2 differs from µ1,µ3 and µ4
# µ4 differs from µ1,µ2 and µ3
plot(model)

#Answer to The Problem: 3.7(d)
# The normal probability plot of the residuals show that there is nothing unusual
# in the normality assumption.
#Answer to The Problem: 3.7(e)
# The residuals vs. the predicted tensile strength plot looks almost 
# rectangular, which indicates the constant variance. 
# In the analysis of variance we also see that the plot's minimum and maximum points 
# of all treatments are in a straight line.
#Answer to The Problem: 3.7(f)
library(car)
## Loading required package: carData
scatterplot(Ten_Str ~ Mix_Tech, data = dat, smoother = FALSE, grid = FALSE, frame = FALSE)

# The plot also shows the sample average for each treatment and the 
# 95% confidence interval on the treatment mean.
# Problem: 3.10
library(agricolae)
Cotton_Wt_Percent <- c("15","15","15","15","15","20","20","20","20","20","25","25","25","25","25","30","30","30","30","30","35","35","35","35","35")
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)
dat1 <- data.frame(Cotton_Wt_Percent,Obs)
dat1
dat1$Cotton_Wt_Percent <- as.factor(dat1$Cotton_Wt_Percent)
dat1$Obs <- as.numeric(dat1$Obs)
str(dat1)
## 'data.frame':    25 obs. of  2 variables:
##  $ Cotton_Wt_Percent: Factor w/ 5 levels "15","20","25",..: 1 1 1 1 1 2 2 2 2 2 ...
##  $ Obs              : num  7 7 15 11 9 12 17 12 18 18 ...
model2 <- aov(Obs~Cotton_Wt_Percent,data=dat1)
summary(model2)
##                   Df Sum Sq Mean Sq F value   Pr(>F)    
## Cotton_Wt_Percent  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
LSD.test(model2,"Cotton_Wt_Percent",console = TRUE)
## 
## Study: model2 ~ "Cotton_Wt_Percent"
## 
## LSD t Test for Obs 
## 
## Mean Square Error:  8.06 
## 
## Cotton_Wt_Percent,  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
#Answer to The Problem: 3.10(b)
# Hypothesis: 
# Null Hypothesis (Ho): u1 = u2, u1 = u3, u1 = u4, u1 = u5, u2 = u3, u2 = u4, u2 = u5, u3 = u4, u3 = u5, u4 = u5.
# Alternative Hypothesis (Ha): at least one of the (ui) differs.
# From the above fishers test we see that mean of 30% is different than 25%,20%,35% 
# and 15%. mean of 25% is similar to mean 20% but different than 30%,35% and 15%
# mean of 20% is similar to mean 25% but different than 30%,35% and 15%
# mean of 35% is similar to mean 15% but different than 20%,25% and 30%
# mean of 15% is similar to mean 35% but different than 20%,25% and 30%
plot(model2)

#Answer to The Problem: 3.10(c)
# The normal probability plot of the residuals show that there is nothing unusual
# in the normality assumption.
# Also from residual to fitted values plot we see that points fairly lie in 
# rectangular shape, which shows the assumption of constant variance.
# Hence the model is adequate.
# Problem: 3.44
library(pwr)
pwr.anova.test(k=4,n=NULL,f=sqrt(((10)^2)/25) ,sig.level = 0.05 , power=0.90)
## 
##      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
#Answer to The Problem: 3.44
# Hence we need 3 observations from each population.
# Problem: 3.45
pwr.anova.test(k=4,n=NULL,f=sqrt(((10)^2)/36) ,sig.level = 0.05 , power=0.90)
## 
##      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
#Answer to The Problem: 3.45(a)
# It did increase the sample number in fraction wise compared to the previous 
# problem, but since it is 2.518782 and  after rounded up to the next integer value
# we need 3 observations from each population.
pwr.anova.test(k=4,n=NULL,f=sqrt(((10)^2)/49) ,sig.level = 0.05 , power=0.90)
## 
##      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
#Answer to The Problem: 3.45(b)
# It did increase the sample number in fraction wise compared to the previous 
# problem, but since it is 2.939789 and  after rounded up to the next integer value
# we need 3 observations from each population.
#Answer to The Problem: 3.45(c)
# As the estimate of variability increases the sample size also increases
# to ensure the same power of the test
#Answer to The Problem: 3.45(d)
# When there is no prior estimate of variability, sometimes we will generate 
# sample sizes for a range of possible variances to see what effect this has 
# on the size of the experiment. Or to bound the variability in the response, 
# such as “the standard deviation is going to be at least…” or 
# “the standard deviation shouldn’t be larger than…”.

Source Code

library(agricolae)
Mix_Tech <- c("1","1","1","1","2","2","2","2","3","3","3","3","4","4","4","4")
Ten_Str <- c(3129,3000,2865,2890,3200,3300,2975,3150,2800,2900,2985,3050,2600,2700,2600,2765)
dat <- data.frame(Mix_Tech,Ten_Str)
dat$Ten_Str <- as.numeric(dat$Ten_Str)
dat$Mix_Tech <- as.factor(Mix_Tech)
str(dat)
model <- aov(Ten_Str~Mix_Tech,data=dat)
summary(model)
LSD.test(model,"Mix_Tech",console = TRUE)
plot(model)
library(car)
scatterplot(Ten_Str ~ Mix_Tech, data = dat, smoother = FALSE, grid = FALSE, frame = FALSE)
library(agricolae)
Cotton_Wt_Percent <- c("15","15","15","15","15","20","20","20","20","20","25","25","25","25","25","30","30","30","30","30","35","35","35","35","35")
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)
dat1 <- data.frame(Cotton_Wt_Percent,Obs)
dat1
dat1$Cotton_Wt_Percent <- as.factor(dat1$Cotton_Wt_Percent)
dat1$Obs <- as.numeric(dat1$Obs)
str(dat1)
model2 <- aov(Obs~Cotton_Wt_Percent,data=dat1)
summary(model2)
LSD.test(model2,"Cotton_Wt_Percent",console = TRUE)
plot(model2)
library(pwr)
pwr.anova.test(k=4,n=NULL,f=sqrt(((10)^2)/25) ,sig.level = 0.05 , power=0.90)
pwr.anova.test(k=4,n=NULL,f=sqrt(((10)^2)/36) ,sig.level = 0.05 , power=0.90)
pwr.anova.test(k=4,n=NULL,f=sqrt(((10)^2)/49) ,sig.level = 0.05 , power=0.90)