3.23
t1 <- c(17.6,18.9,16.3,17.4,20.1,21.6)
t2 <- c(16.9,15.3,18.6,17.1,19.5,20.3)
t3 <- c(21.4,23.6,19.4,18.5,20.5,22.3)
t4 <- c(19.3,21.1,16.9,17.5,18.3,19.8)
dat <- data.frame(t1,t2,t3,t4)
print(dat)
## t1 t2 t3 t4
## 1 17.6 16.9 21.4 19.3
## 2 18.9 15.3 23.6 21.1
## 3 16.3 18.6 19.4 16.9
## 4 17.4 17.1 18.5 17.5
## 5 20.1 19.5 20.5 18.3
## 6 21.6 20.3 22.3 19.8
library(tidyr)
dat <- pivot_longer(dat, c(t1,t2,t3,t4))
aov.model <- aov(value~name,data=dat)
summary(aov.model)
## 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
P value is obtained as 0.525 > 0.05, so we cannot reject null hypothesis.So this indicates that the fluids do not differ.
boxplot(value~name, data=dat, xlab = "fluids", ylab = "life", main="effective life of the fluids")
By looking at the plot I select fluid 3.
plot(aov.model, 1)
As the spread is similar for the samples , assumption that variances are
equal is supported
plot(aov.model, 2)
As the points are closely linear assumption of normality is
supported.
3.28)
s1 <- c(110,157,194,178)
s2 <- c(1,2,4,18)
s3 <- c(880,1256,5276,4355)
s4 <- c(7,5,29,2)
s <- data.frame(s1,s2,s3,s4)
x <- data.frame(rep(1,4),rep(2,4),rep(3,4),rep(4,4))
library(tidyr)
s <- pivot_longer(s, c(s1,s2,s3,s4))
s <- data.frame(s)
aov1 <- aov(value~name, data=s)
summary(aov1)
## Df Sum Sq Mean Sq F value Pr(>F)
## name 3 24993229 8331076 6.874 0.00601 **
## Residuals 12 14543199 1211933
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
No.As p value is 0.00601<0.05 we reject null hypothesis.
plot(aov1, 1)
The spread is different for different samples so assumption of equal variance is not supported.
plot(aov1, 2)
The graph is non-linear.SO, assumption of normality is not
supported.
library(MASS)
3.29)
r1 <- c(31,1,21,4,1)
r2 <- c(62,40,24,30,35)
r3 <- c(53,27,120,97,68)
r <- data.frame(r1,r2,r3)
r <- pivot_longer(r, c(r1,r2,r3))
aov2 <- aov(value ~ name, data=r)
summary(aov2)
## Df Sum Sq Mean Sq F value Pr(>F)
## name 2 9481 4740 8.218 0.00565 **
## Residuals 12 6922 577
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
No. as p value is 0.00565< 0.05 we reject null hypothysis.
plot(aov2, 1)
Yes.spread is very different from samples so assumption of equal variance is not supportes.
plot(aov2, 2)
The assumption of normality is supported.
3.51)
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
p value is 0.1015>0.05, So we can reject null hypothesis.This indicates that the fluids do not differ.Compared to ANOVA the conclusion is same.
3.52)
Yes the results of Kruskal-Wallis test do not assume normality unlike ANOVA does.Kruskal Wallis test would be valid if the data doesn’t show normality, but the data demonstrates it.