Problem 2.23 Entering the data

flu1<-c(17.6,18.9,16.3,17.4,20.1,21.6)
flu2<-c(16.9,15.3,18.6,17.1,19.5,20.3)
flu3<-c(21.4,23.6,19.4,18.5,20.5,22.3)
flu4<-c(19.3,21.1,16.9,17.5,18.3,19.8)
dat<-data.frame(flu1,flu2,flu3,flu4)
library(tidyr)
dat<-pivot_longer(dat,c(flu1,flu2,flu3,flu4))

PartA: Is there any indication that the fluids differ? Use alpha 0.05.

Performing Anova Test

Null Hypothesis: All means are equal

Alternate Hypothesis: Atleast one mean is different

FluidAOV<-aov(value~name,data = dat)
summary(FluidAOV)
##             Df Sum Sq Mean Sq F value Pr(>F)  
## name         3  30.16   10.05   3.047 0.0525 .
## Residuals   20  65.99    3.30                 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Since our P value is greater than alpha which means we fail to reject the null hypothesis.

PartB: Which fluid would you select, given that the objective is long life?

meanflu1=mean(flu1)
meanflu2=mean(flu2)
meanflu3=mean(flu3)
meanflu4=mean(flu4)

Since the mean of fluid 3 is highest therefore it makes perfect sense to select that.

PartC: Analyze the residuals from this experiment. Are the basic analysis of variance assumptions satisfied?

plot(FluidAOV)

From the “Residuals vs Fitted” graph we see that there is constant variance and from the normality chart we see that most of the data points lie in a straight lie hence data is normal too. Therefore, the assumptions of anova are satisfied.

Problem 3.28 Entering the data

Material1<-c(110,157,194,178)
Material2<-c(1,2,4,18)
Material3<-c(880,1256,5276,4355)
Material4<-c(495,7040,5307,10050)
Material5<-c(7,5,29,2)
Table <- data.frame(Material1,Material2,Material3,Material4,Material5)
library(tidyr)
Tablelong<-pivot_longer(Table,c(Material1,Material2,Material3,Material4,Material5))

PartA: Is there any indication that the fluids differ? Use alpha 0.05.

Performing Anova Test

Null Hypothesis: All means are equal

Alternate Hypothesis: Atleast one mean is different

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

Since the p value is less than alpha we reject the null hypothesis.

PartB: Plot the residuals versus the predicted response. Construct a normal probability plot of the residuals. What information is conveyed by these plots?

plot(TableAOV)

From the “Residuals vs Fitted” graph we see that there is no constant variance and from the normality chart we see that majority of the data points does not lie in a straight lie hence data is not normal. Therefore, the assumptions of anova are not satisfied.

PartC: Based on your answer to part (b) conduct another analysis of the failure time data and draw appropriate conclusions.

kruskal.test(value ~ name, data = Tablelong)
## 
##  Kruskal-Wallis rank sum test
## 
## data:  value by name
## Kruskal-Wallis chi-squared = 16.873, df = 4, p-value = 0.002046

Since the p value is less than alpha = 0.05 we again reject the null hypothesis.

Problem 3.29 Entering the data

Method1<-c(31,10,21,4,1)
Method2<-c(62,40,24,30,35)
Method3<-c(53,27,120,97,68)
datMethod<-data.frame(Method1,Method2,Method3)
library(tidyr)
Methodlong<-pivot_longer(datMethod,c(Method1,Method2,Method3))

PartA: Is there any indication that the fluids differ? Use alpha 0.05

Performing Anova Test

Null Hypothesis: All means are equal

Alternate Hypothesis: Atleast one mean is different

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

Since our P value is smaller than alpha which means we reject the null hypothesis and hence one of the means is different.

PartB: Plot the residuals versus the predicted response. Construct a normal probability plot of the residuals. Are there potential concerns about the validity of the assumptions?

plot(MethodAOV)

From the “Residuals vs Fitted” graph we see that data does not have constant variance and from the normality chart we see that most of the data points do not lie in a straight lie hence data is not normal too. Therefore, the assumptions of anova are not satisfied.

PartC: Based on your answer to part (b) conduct another analysis of the particle count data and draw appropriate conclusions.

kruskal.test(Methodlong$value ~ Methodlong$name,data = datMethod)
## 
##  Kruskal-Wallis rank sum test
## 
## data:  Methodlong$value by Methodlong$name
## Kruskal-Wallis chi-squared = 8.54, df = 2, p-value = 0.01398

Since the p-value is much smaller than the alpha = 0.05, therefore we again reject the null hypothesis and hence, there is atleast one mean different.

Problem 3.51

Use the Kruskal–Wallis test for the experiment in Problem 3.23. Compare the conclusions obtained with those from the usual analysis of variance.

kruskal.test(value~name,data = dat)
## 
##  Kruskal-Wallis rank sum test
## 
## data:  value by name
## Kruskal-Wallis chi-squared = 6.2177, df = 3, p-value = 0.1015

Since, in the Anova test the p-value and the alpha were approximately same it was difficult to comment. But in the Kruskal Wallis test we failed to reject the null hypothesis with greater confidence because the p value was much larger than alpha = 0.05.

Problem 3.52

Use the Kruskal–Wallis test for the experiment in Problem 3.23. Are the results comparable to those found by the usual analysis of variance?

kruskal.test(value~name,data = dat)
## 
##  Kruskal-Wallis rank sum test
## 
## data:  value by name
## Kruskal-Wallis chi-squared = 6.2177, df = 3, p-value = 0.1015

Yes, the results are comparable to each other. This is because Kruskal Wallis test does not require normality as its assumptions but Anova does.