Suppose we wish to design a new experiment that tests for a significant difference between the mean effective life of these 4 insulating fluids at an accelerated load of 35kV. The variance of fluid life is estimated to be 4.5hrs based on preliminary data. We would like this test to have a type 1 error probability of 0.05, and for this test to have an 80% probability of rejecting the assumption that the mean life of all the fluids are the same if there is a difference greater than 1 hour between the mean lives of the fluids.
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/sqrt(4.5)),sig.level=0.05,power=0.80)
##
## Balanced one-way analysis of variance power calculation
##
## k = 4
## n = 6.842217
## f = 0.686589
## sig.level = 0.05
## power = 0.8
##
## NOTE: n is number in each group
We will need 9 samples of each fluid in order to achieve this design level.
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((.5)^2/sqrt(4.5)),sig.level=0.05,power=0.80)
##
## Balanced one-way analysis of variance power calculation
##
## k = 4
## n = 24.12736
## f = 0.3432945
## sig.level = 0.05
## power = 0.8
##
## NOTE: n is number in each group
We would need 25 samples from each liquid in order to achieve this design level.
The effective life of insulating fluids at an accelerated load of 35kV is being studied. Test data have been obtained for the four types of fluid. The data from this experiment is given below:
type1 <- c(17.6 ,18.9 ,16.3 ,17.4 ,20.1, 21.6)
type2 <- c(16.9 ,15.3 ,18.6, 17.1 ,19.5 ,20.3)
type3 <- c(21.4 ,23.6 ,19.4 ,18.5 ,20.5, 22.3)
type4 <- c(19.3 ,21.1, 16.9 ,17.5 ,18.3, 19.8)
dafr <- data.frame(type1,type2,type3,type4)
Given that n=6 samples of each fluid type were collected, with what power will a hypothesis test with an a=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)^2/sd(as.matrix(dafr))),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
We will have a power of 84.8% with the design criteria given.
Test the hypothesis that the life of fluids is the same against the alternative that they differ at an =0.10 level of significance (Remember to enter the data in a tidy format when using R, or to pivot_longer to a tidy format using tidyr ) 1 hour between the mean lives of the tested fluids?
dafr2 <- cbind(stack(dafr[1:4]))
atest <- aov(values~ind,dafr2)
summary(atest)
## 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
Our p value is less than .1 so we do reject the null hypothesis. There is a difference between fluid types.
Is the model adequate? (show plots and comment)
plot(atest)
The model does look adequete, since we do not see any patterns that would indicate large differences in variability or violations of normality.
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.
TukeyHSD(atest,conf.level = .9)
## Tukey multiple comparisons of means
## 90% family-wise confidence level
##
## Fit: aov(formula = values ~ ind, data = dafr2)
##
## $ind
## diff lwr upr p adj
## type2-type1 -0.7000000 -3.2670196 1.8670196 0.9080815
## type3-type1 2.3000000 -0.2670196 4.8670196 0.1593262
## type4-type1 0.1666667 -2.4003529 2.7336862 0.9985213
## type3-type2 3.0000000 0.4329804 5.5670196 0.0440578
## type4-type2 0.8666667 -1.7003529 3.4336862 0.8413288
## type4-type3 -2.1333333 -4.7003529 0.4336862 0.2090635
plot(TukeyHSD(atest,conf.level = .9))
From the graph, we can see that there is a significant difference in means between fluid types 3 and 2.
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
pwr.anova.test(k=4,n=NULL,f=sqrt((.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
type1 <- c(17.6 ,18.9 ,16.3 ,17.4 ,20.1, 21.6)
type2 <- c(16.9 ,15.3 ,18.6, 17.1 ,19.5 ,20.3)
type3 <- c(21.4 ,23.6 ,19.4 ,18.5 ,20.5, 22.3)
type4 <- c(19.3 ,21.1, 16.9 ,17.5 ,18.3, 19.8)
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
dafr <- data.frame(type1,type2,type3,type4)
dafr2 <- cbind(stack(dafr[1:4]))
atest <- aov(values~ind,dafr2)
summary(atest)
## 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
plot(atest)
TukeyHSD(atest,conf.level = .9)
## Tukey multiple comparisons of means
## 90% family-wise confidence level
##
## Fit: aov(formula = values ~ ind, data = dafr2)
##
## $ind
## diff lwr upr p adj
## type2-type1 -0.7000000 -3.2670196 1.8670196 0.9080815
## type3-type1 2.3000000 -0.2670196 4.8670196 0.1593262
## type4-type1 0.1666667 -2.4003529 2.7336862 0.9985213
## type3-type2 3.0000000 0.4329804 5.5670196 0.0440578
## type4-type2 0.8666667 -1.7003529 3.4336862 0.8413288
## type4-type3 -2.1333333 -4.7003529 0.4336862 0.2090635
plot(TukeyHSD(atest,conf.level = .9))