Problem 3.23
library(agricolae)
Fluidtype<-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 <- data.frame(Fluidtype, Type)
Data$Type <- as.factor(Data$Type)
str(Data)
## 'data.frame': 24 obs. of 2 variables:
## $ Fluidtype: num 17.6 18.9 16.3 17.4 20.1 21.6 16.9 15.3 18.6 17.1 ...
## $ Type : Factor w/ 4 levels "1","2","3","4": 1 1 1 1 1 1 2 2 2 2 ...
b<-aov(Fluidtype~Type, data = Data)
summary(b)
## 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
plot(b)




Fluid1<-c(17.6,18.9,16.3,17.4,20.1,21.6)
mean(Fluid1)
## [1] 18.65
Fluid2<-c(16.9,15.3,18.6,17.1,19.5,20.3)
mean(Fluid2)
## [1] 17.95
Fluid3<-c(21.4,23.6,19.4,18.5,20.5,22.3)
mean(Fluid3)
## [1] 20.95
Fluid4<-c(19.3,21.1,16.9,17.5,18.3,19.8)
mean(Fluid4)
## [1] 18.81667
Null Hypothesis(H0): mu1=mu2=mu3=mu4=mu
Alternate Hypothesis(H1): at least one of mu1,mu2,mu3,mu4 differs
Here the p value is slightly more than 0.05, so we fail to reject null hypothesis.
a)There is no indication that the fluids differ.
b)We would you select fluid 3 , given that the objective is long life.
c)After analyzing the residuals from this experiments, we can say that basic analysis of varience assumptions is satisfied.
Problem 3.28
library(agricolae)
material<-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<-data.frame(material,Type)
Data$Type<- as.factor(Data$Type)
str(Data)
## 'data.frame': 20 obs. of 2 variables:
## $ material: num 110 157 194 178 1 ...
## $ Type : Factor w/ 5 levels "1","2","3","4",..: 1 1 1 1 2 2 2 2 3 3 ...
av<-aov(material~Type,data = Data)
summary(av)
## 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
plot(av)




library(MASS)
boxplot(Data$material~Data$Type)

boxcox(material~Type)

m <- log(material)
qqnorm(m)

plot(m~Type,xlab="Materials",ylab="Failure Time",main="Variance check")

av <- aov(m~Type, data = Data)
summary(av)
## 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
Null Hypothesis(H0): mu1=mu2=mu3=mu4=mu5=mu
Alternate Hypothesis(H1): at least one of mu1,mu2,mu3,mu4,mu5 differs
a)Here p value is less than 0.05, so we reject null hypotheis. So we can say that materials have different effects on mean failure time.
b)Here from the plots we can say that the variences are not stable and data is not normally distributed, so we need to do a boxcox transfromation.
c)As the variences are not stable and data is not normal, we need to do a log transformation because the maximum value is close to zero.
Probelm 3.29
library(agricolae)
method<-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<-data.frame(method,Type)
Data$Type<-as.factor(Data$Type)
str(Data)
## 'data.frame': 15 obs. of 2 variables:
## $ method: num 31 10 21 4 1 62 40 24 30 35 ...
## $ Type : Factor w/ 3 levels "1","2","3": 1 1 1 1 1 2 2 2 2 2 ...
av1<-aov(method~Type,data = Data)
summary(av1)
## 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
plot(av1)




library(MASS)
boxplot(Data$method~Data$Type)

boxcox(method~Type)

lambda<-0.5
Tmethod<-method^(lambda)
boxplot(Tmethod~Data$Type)

DataT <- cbind(Tmethod,Type)
DataT <- data.frame(DataT)
DataT$Type <- as.factor(DataT$Type)
str(DataT)
## 'data.frame': 15 obs. of 2 variables:
## $ Tmethod: num 5.57 3.16 4.58 2 1 ...
## $ Type : Factor w/ 3 levels "1","2","3": 1 1 1 1 1 2 2 2 2 2 ...
aov.modelT<-aov(Tmethod~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)




Null Hypothesis(H0): mu1=mu2=mu3=mu4=mu
Alternate Hypothesis(H1): at least one of mu1,mu2,mu3,mu4 differs
a)Here p value is less than 0.05, so we reject the null hypotheis. No, all methods do not have the same effect on mean particle count.
b)From the graphs we can say that there are potential concerns as the variences are not stable and data is not normally distributed.
c)As variences are not stable and data is not normally distributed, we need to do a boxcox transformation.
Probelm 3.51
library(agricolae)
Fluidtype<-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 <- data.frame(Fluidtype, Type)
Data$Type <- as.factor(Data$Type)
str(Data)
## 'data.frame': 24 obs. of 2 variables:
## $ Fluidtype: num 17.6 18.9 16.3 17.4 20.1 21.6 16.9 15.3 18.6 17.1 ...
## $ Type : Factor w/ 4 levels "1","2","3","4": 1 1 1 1 1 1 2 2 2 2 ...
kruskal.test(Fluidtype~Type,data = Data)
##
## Kruskal-Wallis rank sum test
##
## data: Fluidtype by Type
## Kruskal-Wallis chi-squared = 6.2177, df = 3, p-value = 0.1015
Null Hypothesis(H0): mu1=mu2=mu3=mu4=mu
Alternate Hypothesis(H1): at least one of mu1,mu2,mu3,mu4 differs
From the test,the p value is greater than 0.05,so we can say that we failed to reject null hypothesis and the conclusions obtained with those from the usual analysis of variance and Kruskal–Wallis test are the same as we fail to reject the null hypothesis in both cases.