Problem 3.23

Null hypothesis: All the mean lifes are equal. Alternative hypothesis: At least one mean differs

library(agricolae)
## Warning: package 'agricolae' was built under R version 4.0.5
r1 <- c(17.6,18.9,16.3,17.4,20.1,21.6)
r2 <- c(16.9,15.3,18.6,17.1,19.5,20.3)
r3 <- c(21.4,23.6,19.4,18.5,20.5,22.3)
r4 <- c(19.3,21.1,16.9,17.5,18.3,19.8)
life <- c(r1,r2,r3,r4)
type <- c(rep(1,6),rep(2,6),rep(3,6),rep(4,6))
dat1 <- cbind(life,type)
dat1 <- as.data.frame(dat1)
dat1$type <- as.factor(dat1$type)
aov.model<-aov(life~type,data=dat1)
summary(aov.model)
##             Df Sum Sq Mean Sq F value Pr(>F)  
## type         3  30.17   10.05   3.047 0.0525 .
## Residuals   20  65.99    3.30                 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
LSD.test(aov.model,"type",p.adj = "none",console=TRUE)
## 
## Study: aov.model ~ "type"
## 
## LSD t Test for life 
## 
## Mean Square Error:  3.299667 
## 
## type,  means and individual ( 95 %) CI
## 
##       life      std r      LCL      UCL  Min  Max
## 1 18.65000 1.952178 6 17.10309 20.19691 16.3 21.6
## 2 17.95000 1.854454 6 16.40309 19.49691 15.3 20.3
## 3 20.95000 1.879096 6 19.40309 22.49691 18.5 23.6
## 4 18.81667 1.554885 6 17.26975 20.36358 16.9 21.1
## 
## Alpha: 0.05 ; DF Error: 20
## Critical Value of t: 2.085963 
## 
## least Significant Difference: 2.187666 
## 
## Treatments with the same letter are not significantly different.
## 
##       life groups
## 3 20.95000      a
## 4 18.81667     ab
## 1 18.65000      b
## 2 17.95000      b
plot(aov.model)

(a) At 0.05 level of significance, there is no difference. However, the P-value is 0.0525, which is slightly larger than 0.05, therefore the means probably differ
(b) From the Fisher LSD method, fluid 3 should be selected, as it has the largest mean life
(c) The data from the residual plots all have roughly the same width, indicating that the variance assumption is satisfied

Problem 3.28

Null hypothesis: All the mean failure times are equal. Alternative hypothesis: At least one mean differs

library(MASS)
## Warning: package 'MASS' was built under R version 4.0.5
r1 <- c(110,157,194,178)
r2 <- c(1,2,4,18)
r3 <- c(880,1256,5276,4355)
r4 <- c(495,7040,5307,10050)
r5 <- c(7,5,29,2)
failure_time <- c(r1,r2,r3,r4,r5)
material <- c(rep(1,4),rep(2,4),rep(3,4),rep(4,4),rep(5,4))
dat2 <- cbind(failure_time,material)
dat2 <- as.data.frame(dat2)
dat2$material <- as.factor(dat2$material)
aov.model<-aov(failure_time~material,data=dat2)
summary(aov.model)
##             Df    Sum Sq  Mean Sq F value  Pr(>F)   
## material     4 103191489 25797872   6.191 0.00379 **
## Residuals   15  62505657  4167044                   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
plot(aov.model)

boxcox(failure_time~material)

dat2$failure_time <- log(dat2$failure_time)
aov.model<-aov(failure_time~material,data=dat2)
plot(aov.model)

summary(aov.model)
##             Df Sum Sq Mean Sq F value   Pr(>F)    
## material     4 165.06   41.26   37.66 1.18e-07 ***
## Residuals   15  16.44    1.10                     
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
(a) The P-value is 0.00379 , which is much smaller than 0.05, therefore the null hypothesis is rejected and at least one mean differs
(b) The residuals plot has significantly different data widths between the populations, implying that the variance assumption is not satisfied. The normal probability plot has a S-shape, therefore the normality assumption is not valid either. Because the variance assumption is not satisified, a data transformation is needed.
(c) after performing the Box-Cox transformation, lambda was found to be zero. Because the lambda value was zero, a natural log transformation was selected to be used on the data. After checking the residual plots of the transformed data, it was determined that the normality and constant variance assumptions were satisifed. Performing ANOVA again on the data, it was determined that at least one mean differs

Problem 3.29

Null hypothesis: All the mean particle counts are equal Alternative hypothesis: At least one mean differs

r1 <- c(31,10,21,4,1)
r2 <- c(62,40,24,30,35)
r3 <- c(53,27,120,97,68)
count <- c(r1,r2,r3)
method <- c(rep(1,5),rep(2,5),rep(3,5))
dat3 <- cbind(count,method)
dat3 <- as.data.frame(dat3)
dat3$method <- as.factor(dat3$method)
aov.model<-aov(count~method,data=dat3)
summary(aov.model)
##             Df Sum Sq Mean Sq F value  Pr(>F)   
## method       2   8964    4482   7.914 0.00643 **
## Residuals   12   6796     566                   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
plot(aov.model)

boxcox(count~method)

dat3$count <- sqrt(dat3$count)
aov.model<-aov(count~method,data=dat3)
summary(aov.model)
##             Df Sum Sq Mean Sq F value  Pr(>F)   
## method       2  63.90   31.95    9.84 0.00295 **
## Residuals   12  38.96    3.25                   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
(a) The P-value is 0.00643 , which is much smaller than 0.05, therefore the null hypothesis is rejected and at least one mean differs
(b) The residual plots indicate that both the constant variance and normality assumptions are not valid for this data. Therefore, a data transformation must be applied before proceeding.
(c) After performing a Box-Cox plot, a square root transformation (lambda = 0.5) was performed on the data. The ANOVA on the transformed data reiterates that the null hypothesis can be rejected, with the P-value = 0.00295

Problem 3.51

kruskal.test(life~type,data=dat1)
## 
##  Kruskal-Wallis rank sum test
## 
## data:  life by type
## Kruskal-Wallis chi-squared = 6.2177, df = 3, p-value = 0.1015
Based off the Kruskal-Wilis test, the null hypothesis would be accepted. This is the same result that was determined from the ANOVA from problem 3.23, therefore the conclusions are the same.