Question 1
Part A:How many samples of each fluid will need to be collected to achieve this design criterion?
library(pwr)
pwr.anova.test(k=4,n=NULL,f=sqrt((1)^2/4.5),sig.level = 0.05,power = 0.8)
##
## 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
Therefore, we need to collect 13.28 that is 14 samples to achieve this design criterion.
Part B:Suppose we wish to have an 80% probability of detecting a difference between mean fluid lives of 30minutes, how many samples would need to be collected?
pwr.anova.test(k=4,n=NULL,f=sqrt((0.5)^2/4.5),sig.level = 0.05,power = 0.8)
##
## 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
Therefore, we need to collect 50.04 that is 51 samples.
Question 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)
dat<-data.frame(fluid1,fluid2,fluid3,fluid4)
stacked_dat<-stack(dat)
std<-sd(stacked_dat$values)
Part A:Given that n=6 samples of each fluid type were collected, with what power will a hypothesis test with an =0.10 level of significance be able to detect a difference of 1 hour between the mean lives of the tested fluids?
pwr.anova.test(k=4,n=6,f=sqrt(1/std), sig.level = 0.1, power = NULL)
##
## Balanced one-way analysis of variance power calculation
##
## k = 4
## n = 6
## f = 0.6993349
## sig.level = 0.1
## power = 0.8485013
##
## NOTE: n is number in each group
Power is 0.84
Part B:Test the hypothesis that the life of fluids is the same against the alternative that they differ at an =0.10 level of significance
Null Hypothesis: All means are equal Alternate Hypothesis: Some means are equal
model<-aov(values~ind,data=stacked_dat)
summary(model)
## Df Sum Sq Mean Sq F value Pr(>F)
## ind 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
As the F values of 3.047 corresponds to P value of 0.0525 with an alpha = 0.1 We can reject the Null hypothesis.
Part C:Is the model adequate?
plot(model)
From the first plot we see that variance of all the groups are roughly
similar. From the second plot we can see that the data seems to be
rougly normally distributed. We conclude that the data satisfies the
requirement of annova test that is the data has to be normally
distributed and should have constant variance. Therefore this model
seems to be adequate.
Part D:Assuming the null hypothesis in question 1 is rejected, which fluids significant differ using a familywise error rate of =0.10 (use Tukey’s test). Include the plot of confidence intervals.
tukey <-TukeyHSD(model,conf.level = 0.9)
plot(tukey)
From the Tukeys Plot and the result we can conclude that the only
significant difference (alpha= 0.1) is between fluid 2 and fluid 3.