Answer to Question No 1

#For Minimum Variability

power.anova.test(groups = 4, n = NULL,
                 between.var =var(c(18,19,19,20)), within.var = 3.5,
                 sig.level = 0.05, power = .8)
## 
##      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

#For Intermediate Variability

power.anova.test(groups = 4, n = NULL,
                 between.var =var(c(18,18.66,19.33,20)), within.var = 3.5,
                 sig.level = 0.05, power = .8)
## 
##      Balanced one-way analysis of variance power calculation 
## 
##          groups = 4
##               n = 18.16131
##     between.var = 0.7414917
##      within.var = 3.5
##       sig.level = 0.05
##           power = 0.8
## 
## NOTE: n is number in each group

#For Maximum 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 = .8)
## 
##      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

##We can consider minimum variability number of Sample needs to collect 21 ##We can consider intermidiate variability number of Sample needs to collect 19 ##We can consider maximum variability number of Sample needs to collect 11

Answer to the Question No:2

library(tidyr)

fluid1<- c(17.6,18.9,16.3,17.4,20.1,21.60)
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 <- as.factor(df$fluid.type)
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 ...

(a) Test The Hypothesis

model_anova <- aov(fluid~fluid.type, data=df) 
summary(model_anova)
##             Df Sum Sq Mean Sq F value Pr(>F)  
## fluid.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

##From the summary we can see that P value 0.0525 is less than the alpha value, so we can reject the null hypothesis, life time of the fuilds are differents.

#(b) Model Adequecy

plot(model_anova)

##From the model we can see that the normality and constant variance assumtion holds.

##(C)

Tukey.test <- TukeyHSD(model_anova, conf.level = .9)
plot(Tukey.test)

#from the tukey test we can observe model 2 and 3 differs from the mean value

#For Minimum Variability

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


#For Intermediate Variability

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

#For Maximum 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 = .8)

## Answer to the Question No:2
library(tidyr)

fluid1<- c(17.6,18.9,16.3,17.4,20.1,21.60)
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 <- as.factor(df$fluid.type)
str(df)

## 2(a) Test The Hypothesis

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

#(b) Model Adequecy
plot(model_anova)

#(c) Tukeys Test
Tukey.test <- TukeyHSD(model_anova, conf.level = .9)
plot(Tukey.test)