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
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)
aov.model<-aov(Life~Type,data=Data)
plot(aov.model)
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)
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
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")
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)
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.
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)
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
part b
aov.model<-aov(Count~Type,data=Data)
plot(aov.model)
library(MASS)
boxplot(Data$Count~Data$Type,xlab="Method Type",ylab="Particle Count",main="Boxplot of Observations")
boxcox(Count~Type)
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)
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