Question No 1 Part A

Power Analysis

library(pwr)
pwr.anova.test(k=4,n=NULL,f=sqrt((1)^2/4.5),sig.level=0.05,power=0.80)
## 
##      Balanced one-way analysis of variance power calculation 
## 
##               k = 4
##               n = 13.28401
##               f = 0.4714045
##       sig.level = 0.05
##           power = 0.8
## 
## NOTE: n is number in each group

So in this case we would need sample sizes of 14 observations from each population.

Question No 1 Part B

library(pwr)
pwr.anova.test(k=4,n=NULL,f=sqrt((0.5)^2/4.5),sig.level=0.05,power=0.80)
## 
##      Balanced one-way analysis of variance power calculation 
## 
##               k = 4
##               n = 50.04922
##               f = 0.2357023
##       sig.level = 0.05
##           power = 0.8
## 
## NOTE: n is number in each group

So in this case we would need sample sizes of 51 observations from each population.

Question No 2 Part A

pwr.anova.test(k=4,n=6,f=sqrt((1)^2/4.5),sig.level=0.1,power=NULL)
## 
##      Balanced one-way analysis of variance power calculation 
## 
##               k = 4
##               n = 6
##               f = 0.4714045
##       sig.level = 0.1
##           power = 0.5334697
## 
## NOTE: n is number in each group

So in this scenario the power to detect a difference of 1 hour between the mean lives of the tested fluids would be 53.3%.

Question No 2 Part B

NULL Hypothesis: mu1=mu2=mu3=mu4=mu

Alternative Hypothesis = Atleast mui differs. i={1,2,3,4}

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(1,1,1,1,1,1,2,2,2,2,2,2,3,3,3,3,3,3,4,4,4,4,4,4)
Type <- as.factor(Type)
Pop <- cbind(Life, Type)
Pop <- data.frame(Pop)
Pop$Type <- as.factor(Pop$Type)
str(Pop)
## 'data.frame':    24 obs. of  2 variables:
##  $ Life: 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 ...
aov.model<-aov(Life~Type,data=Pop)
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
plot(aov.model)

Since our p-value is 0.0525, so we would reject the null hypothesis at a significance level of 0.10, and we would conclude that there’s a signaificant difference between mean lives of the tested fluids.

Question No 2 Part C

So looking at our plots of all four populations, we conclude that model is adequate as the data seems to fulfill the assumptions of normality and constant variance so our ANOVA test results should hold.

Question No 2 Part D

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(1,1,1,1,1,1,2,2,2,2,2,2,3,3,3,3,3,3,4,4,4,4,4,4)
Type <- as.factor(Type)
Pop <- cbind(Life, Type)
Pop <- data.frame(Pop)
Pop$Type <- as.factor(Pop$Type)
str(Pop)
## 'data.frame':    24 obs. of  2 variables:
##  $ Life: 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 ...
aov.model<-aov(Life~Type,data=Pop)
TukeyHSD(aov.model, conf.level = 0.9)
##   Tukey multiple comparisons of means
##     90% family-wise confidence level
## 
## Fit: aov(formula = Life ~ Type, data = Pop)
## 
## $Type
##           diff        lwr       upr     p adj
## 2-1 -0.7000000 -3.2670196 1.8670196 0.9080815
## 3-1  2.3000000 -0.2670196 4.8670196 0.1593262
## 4-1  0.1666667 -2.4003529 2.7336862 0.9985213
## 3-2  3.0000000  0.4329804 5.5670196 0.0440578
## 4-2  0.8666667 -1.7003529 3.4336862 0.8413288
## 4-3 -2.1333333 -4.7003529 0.4336862 0.2090635
plot(TukeyHSD(aov.model))

So Tukey’s test tells us that the Fluid Types 2 & 3 differ from each other at a familywise error rate of a=0.10.

Allcode

library(pwr)
pwr.anova.test(k=4,n=NULL,f=sqrt((1)^2/4.5),sig.level=0.05,power=0.80)
library(pwr)
pwr.anova.test(k=4,n=NULL,f=sqrt((0.5)^2/4.5),sig.level=0.05,power=0.80)
pwr.anova.test(k=4,n=6,f=sqrt((1)^2/4.5),sig.level=0.1,power=NULL)
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(1,1,1,1,1,1,2,2,2,2,2,2,3,3,3,3,3,3,4,4,4,4,4,4)
Type <- as.factor(Type)
Pop <- cbind(Life, Type)
Pop <- data.frame(Pop)
Pop$Type <- as.factor(Pop$Type)
str(Pop)
aov.model<-aov(Life~Type,data=Pop)
summary(aov.model)
plot(aov.model)
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(1,1,1,1,1,1,2,2,2,2,2,2,3,3,3,3,3,3,4,4,4,4,4,4)
Type <- as.factor(Type)
Pop <- cbind(Life, Type)
Pop <- data.frame(Pop)
Pop$Type <- as.factor(Pop$Type)
str(Pop)
aov.model<-aov(Life~Type,data=Pop)
TukeyHSD(aov.model, conf.level = 0.9)
plot(TukeyHSD(aov.model))