problem 3.23

Life <- c(17.6, 18.9, 16.3, 17.4, 20.1, 21.6, 16.9, 15.3, 18.6, 17.1, 19.5, 20.3, 21.4, 23.6, 19.4, 18.5, 20.5, 22.3, 19.3, 21.1, 16.9, 17.5, 18.3, 19.8) 
Type <- c(rep(1,6), rep(2,6), rep(3,6), rep(4,6))
Data <- cbind(Life, Type)
Data <- data.frame(Data)
Data$Type <- as.factor(Data$Type)

Null Hypothesis: Ho: mu1 = mu2 = mu3 = mu4 = mu Alternative Hypothesis: Ha: Atleast one mui differs

aov.model<-aov(Life~Type,data=Data)
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

from the above anova test p value is > than aplha = 0.05

we fail to reject the null hypothesis

TukeyHSD(aov.model)
##   Tukey multiple comparisons of means
##     95% family-wise confidence level
## 
## Fit: aov(formula = Life ~ Type, data = Data)
## 
## $Type
##           diff         lwr       upr     p adj
## 2-1 -0.7000000 -3.63540073 2.2354007 0.9080815
## 3-1  2.3000000 -0.63540073 5.2354007 0.1593262
## 4-1  0.1666667 -2.76873407 3.1020674 0.9985213
## 3-2  3.0000000  0.06459927 5.9354007 0.0440578
## 4-2  0.8666667 -2.06873407 3.8020674 0.8413288
## 4-3 -2.1333333 -5.06873407 0.8020674 0.2090635
plot(TukeyHSD(aov.model))

Fluid1 <- c(17.6, 18.9, 16.3, 17.4, 20.1, 21.6)
Fluid2 <- c(16.9, 15.3, 18.6, 17.1, 19.5, 20.3)
Fluid3 <- c(21.4, 23.6, 19.4, 18.5, 20.5, 22.3)
Fluid4 <- c(19.3, 21.1, 16.9, 17.5, 18.3, 19.8)
A <- mean(Fluid1)
B <- mean(Fluid2)
C <- mean(Fluid3)
D <- mean(Fluid4)

Tukey’s test states that the difference in means of fluid type 3 and 2.

This is the only combination that differs.

fluid type 3 would be Choosen for long life

aov.model<-aov(Life~Type,data=Data)
plot(aov.model)

As shown in the above plots, we can conclude that the data is normally distributed. Also, the residual vs fitted value plot shows that the variance is constant.

problem 3.28

Time <- c(110, 157, 194, 178, 1, 2, 4, 18, 880, 1256, 5276, 4355, 495, 7040, 5307, 10050, 7, 5, 29, 2)
Type <- c(rep(1,4), rep(2,4), rep(3,4), rep(4,4), rep(5,4))
Data <- cbind(Time,Type)
Data <- data.frame(Data)
Data$Type <- as.factor(Data$Type)

Null Hypothesis: Ho: mu1 = mu2 = mu3 = mu4

Alternative Hypothesis: Ha: Atleast one mui differs

aov.model<-aov(Time~Type,data=Data)
summary(aov.model)
##             Df    Sum Sq  Mean Sq F value  Pr(>F)   
## Type         4 103191489 25797872   6.191 0.00379 **
## Residuals   15  62505657  4167044                   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

From the anova, the P-value = 0.00379 which is < alpha = 0.05. Hence we reject the Null Hypothesis.

This indicates that atleast one of the mean differs and does not have the same effect.

plots

aov.model<-aov(Time~Type,data=Data)
plot(aov.model)

### from the result, we can see that neither the normal probability nor the constant variance assumptions are satisfied. there will be huge difference . Thus we need to perform a data transformation.

library(MASS)
boxplot(Data$Time~Data$Type,xlab="Material ",ylab="Failure Time",main="Boxplot observations")

boxcox(Time~Type)

### From the box cox plot, 1 is not in 95% confidence interval which needed that the data required a transformation. Now the function is maximum right next to zero value of lambda, thus we would perform a log transformation of our data.

log transformation

LogTime <- log(Time)
boxplot(LogTime~Data$Type,xlab="Material ",ylab="Failure Time",main="Boxplot Observations")

Now the plots of time observations is much more uniform than before.

DataT <- cbind(LogTime,Type)
DataT <- data.frame(DataT)
DataT$Type <- as.factor(DataT$Type)
aov.modelT<-aov(LogTime~Type,data=DataT)
summary(aov.modelT)
##             Df Sum Sq Mean Sq F value   Pr(>F)    
## Type         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
plot(aov.modelT)

From the results of anova analysis on transformed data,

this time our p-value is so small we can say that atleast one mui differs. Also if we look at the residual plots of transformed data, now we can reasonably conclude that the model is adequate.

problem 3.29

Count <- c(31, 10, 21, 4, 1, 62, 40, 24, 30, 35, 53, 27, 120, 97, 68)
Type <- c(rep(1,5), rep(2,5), rep(3,5))
Data <- cbind(Count,Type)
Data <- data.frame(Data)
Data$Type <- as.factor(Data$Type)

Null Hypothesis: Ho: mu1 = mu2 = mu3 = mu

Alternative Hypothesis: Ha: Atleast one mui differs

aov.model<-aov(Count~Type,data=Data)
summary(aov.model)
##             Df Sum Sq Mean Sq F value  Pr(>F)   
## Type         2   8964    4482   7.914 0.00643 **
## Residuals   12   6796     566                   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

from the result p-value is 0.00643, thus at 0.05 level of significance we reject Ho and we conclude that atleast one mui differs which at least one method differs

part b

aov.model<-aov(Count~Type,data=Data)
plot(aov.model)

from the result plot, we can see that the spread of three methods is not constant and thus we can’t make constant variance So we would perform a transformation of the data.

library(MASS)
boxplot(Data$Count~Data$Type,xlab="Method Type",ylab="Particle Count",main="Boxplot of Observations")

boxcox(Count~Type)

From the result boxcox, 1 is not in 95% confidence interval which confirms data required a transformation. Now the function is maximum close to 0.5 value of lambda, thus we would perform a transformation of our data.

library(MASS)
lambda <- 0.5
TCount<-Count^(lambda)
boxplot(TCount~Data$Type,xlab="Method Type",ylab="Particle Count",main="Boxplot of Observations")

## since in the plots, now the spread of particle count is better than before the transformation, but may not be perfect.

DataT <- cbind(TCount,Type)
DataT <- data.frame(DataT)
DataT$Type <- as.factor(DataT$Type)
aov.modelT<-aov(TCount~Type,data=DataT)
summary(aov.modelT)
##             Df Sum Sq Mean Sq F value  Pr(>F)   
## Type         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
plot(aov.modelT)

From the results of anova analysis on transformed data,the p-value is 0.00295, so aplha = 0.05 level of significance we can say that atleast one mui differs which effect pn particle count. now by seeing the residual plots of transformed data, now we can reasonably consider our model is adequate.

problem 3.51

Life <- c(17.6, 18.9, 16.3, 17.4, 20.1, 21.6, 16.9, 15.3, 18.6, 17.1, 19.5, 20.3, 21.4, 23.6, 19.4, 18.5, 20.5, 22.3, 19.3, 21.1, 16.9, 17.5, 18.3, 19.8) 
Type <- c(rep(1,6), rep(2,6), rep(3,6), rep(4,6))
Data <- cbind(Life, Type)
Data <- data.frame(Data)
Data$Type <- as.factor(Data$Type)
kruskal.test(Life~Type,data=Data)
## 
##  Kruskal-Wallis rank sum test
## 
## data:  Life by Type
## Kruskal-Wallis chi-squared = 6.2177, df = 3, p-value = 0.1015

from the result p-value is 0.1015, thus we fail to reject Ho and that there’s no indication that the fluids differ. These results are the same as we obtained from the anova test