Question number 1

library(pwr)
#min variability test

?power.anova.test
## starting httpd help server ... done
power.anova.test(groups=4,n=NULL,between.var=var(c(18,19,19,20)),within.var=3.5,sig.level=0.05,power=0.80)
## 
##      Balanced one-way analysis of variance power calculation 
## 
##          groups = 4
##               n = 20.08368
##     between.var = 0.6666667
##      within.var = 3.5
##       sig.level = 0.05
##           power = 0.8
## 
## NOTE: n is number in each group
#intermediate variability test

power.anova.test(groups=4,n=NULL,between.var=var(c(18,18.67,19.33,20)),within.var=3.5,sig.level=0.05,power=0.80)
## 
##      Balanced one-way analysis of variance power calculation 
## 
##          groups = 4
##               n = 18.21285
##     between.var = 0.7392667
##      within.var = 3.5
##       sig.level = 0.05
##           power = 0.8
## 
## NOTE: n is number in each group
#max variability
power.anova.test(groups=4,n=NULL,between.var=var(c(18,18,20,20)),within.var=3.5,sig.level=0.05,power=0.80)
## 
##      Balanced one-way analysis of variance power calculation 
## 
##          groups = 4
##               n = 10.56952
##     between.var = 1.333333
##      within.var = 3.5
##       sig.level = 0.05
##           power = 0.8
## 
## NOTE: n is number in each group

Question number 2 (a)

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)

fluid<- c(fluid1, fluid2, fluid3,fluid4)
fluid.type<-c(rep(1,6),rep(2,6),rep(3,6),rep(4,6))
df<- data.frame(fluid.type, fluid)
df
##    fluid.type fluid
## 1           1  17.6
## 2           1  18.9
## 3           1  16.3
## 4           1  17.4
## 5           1  20.1
## 6           1  21.6
## 7           2  16.9
## 8           2  15.3
## 9           2  18.6
## 10          2  17.1
## 11          2  19.5
## 12          2  20.3
## 13          3  21.4
## 14          3  23.6
## 15          3  19.4
## 16          3  18.5
## 17          3  20.5
## 18          3  22.3
## 19          4  19.3
## 20          4  21.1
## 21          4  16.9
## 22          4  17.5
## 23          4  18.3
## 24          4  19.8
aov.model<-aov(fluid~fluid.type,data=df)
summary(aov.model)
##             Df Sum Sq Mean Sq F value Pr(>F)
## fluid.type   1   3.67   3.675   0.874   0.36
## Residuals   22  92.48   4.204

The p value (0.0525) is less than the significance level. So, we reject null hypothesis. There is significant difference between the life of the fluids.

Question number 2(b)

plot(aov.model)

Conclusion:

Residuals vs Fitted plot: The residuals scattered randomly with in the range of fitted values, no pattern is observed so we can assume constant variance .

We can see from the Normal Probability plot, most of the values are pretty much in line with a single straight line; hence normality is indicated.

Question number 2(c)

df$fluid.type <- as.factor(df$fluid.type)
df
##    fluid.type fluid
## 1           1  17.6
## 2           1  18.9
## 3           1  16.3
## 4           1  17.4
## 5           1  20.1
## 6           1  21.6
## 7           2  16.9
## 8           2  15.3
## 9           2  18.6
## 10          2  17.1
## 11          2  19.5
## 12          2  20.3
## 13          3  21.4
## 14          3  23.6
## 15          3  19.4
## 16          3  18.5
## 17          3  20.5
## 18          3  22.3
## 19          4  19.3
## 20          4  21.1
## 21          4  16.9
## 22          4  17.5
## 23          4  18.3
## 24          4  19.8
str(df)
## 'data.frame':    24 obs. of  2 variables:
##  $ fluid.type: Factor w/ 4 levels "1","2","3","4": 1 1 1 1 1 1 2 2 2 2 ...
##  $ fluid     : num  17.6 18.9 16.3 17.4 20.1 21.6 16.9 15.3 18.6 17.1 ...
aov.model <- aov(fluid~fluid.type, data = df)
aov.model
## Call:
##    aov(formula = fluid ~ fluid.type, data = df)
## 
## Terms:
##                 fluid.type Residuals
## Sum of Squares    30.16500  65.99333
## Deg. of Freedom          3        20
## 
## Residual standard error: 1.816498
## Estimated effects may be unbalanced
library(car)
## Loading required package: carData
?TukeyHSD
TukeyHSD(aov.model)
##   Tukey multiple comparisons of means
##     95% family-wise confidence level
## 
## Fit: aov(formula = fluid ~ fluid.type, data = df)
## 
## $fluid.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))

From the given plot, we can see that 0 does notlie in the confidence interval for fluid 3 and 2. So there is significant difference between the 2 and 3.

Complete R code

#Question number 1
library(pwr)
#min variability test

?power.anova.test
power.anova.test(groups=4,n=NULL,between.var=var(c(18,19,19,20)),within.var=3.5,sig.level=0.05,power=0.80)

#intermediate variability test

power.anova.test(groups=4,n=NULL,between.var=var(c(18,18.67,19.33,20)),within.var=3.5,sig.level=0.05,power=0.80)

#max variability
power.anova.test(groups=4,n=NULL,between.var=var(c(18,18,20,20)),within.var=3.5,sig.level=0.05,power=0.80)


#Question number 2
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)

fluid<- c(fluid1, fluid2, fluid3,fluid4)
fluid.type<-c(rep(1,6),rep(2,6),rep(3,6),rep(4,6))
df<- data.frame(fluid.type, fluid)
df


aov.model<-aov(fluid~fluid.type,data=df)
summary(aov.model)
plot(aov.model)

df$fluid.type <- as.factor(df$fluid.type)
df
str(df)
aov.model <- aov(fluid~fluid.type, data = df)
aov.model

library(car)
?TukeyHSD
TukeyHSD(aov.model)
plot(TukeyHSD(aov.model))