Question 1
Here we have 4 polulations, diff mean =1, power= 80%, error probability=0.05, type 1, variance= 4.5, f is actually the effect size.
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
n = 13.28401, so we need 14 samples for each fluid.
Here we have 4 polulations, diff mean =0.5, power= 80%, error probability=0.05, type 1, variance= 4.5, f is actually the effect size.
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
n = 50.04922, so we need 51 samples for each fluid.
Question 2
(a )
Here we have k=4, n=6, alpha= 0.1, diff mean =1, we need to obtain variance first.
obs <- 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)
obs
## [1] 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
## [16] 18.5 20.5 22.3 19.3 21.1 16.9 17.5 18.3 19.8
var(obs)
## [1] 4.180797
pwr.anova.test(k=4,n=6,f=sqrt((1)^2/var(obs)),sig.level=0.1,power=NULL)
##
## Balanced one-way analysis of variance power calculation
##
## k = 4
## n = 6
## f = 0.4890694
## sig.level = 0.1
## power = 0.5618141
##
## NOTE: n is number in each group
k = 4
n = 6
f = 0.4890694
sig.level = 0.1
power = 0.5618141
(b)
null hypothesis: \(H_0: \mu_{1}=\mu_{2}=\cdots =\mu_{i}=\mu\)
alternative hypothesis: \(H_1:\) at least one \(\mu_{i}\) differs
type <- c(rep(1,6),rep(2,6),rep(3,6),rep(4,6))
dat1 <- cbind(obs,type)
dat1 <- as.data.frame(dat1)
dat1$type <- as.factor(dat1$type)
str(dat1)
## 'data.frame': 24 obs. of 2 variables:
## $ obs : 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(obs~type,data=dat1)
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
Since P = 0.0525 < 0.1, we reject null hythesis. The life of fluids differs.
(c)
plot(aov.model)




From the residual plot, variances are very close to each other, which means variances are equal. (strong assumption)
From qqnorm plot, points are aligned by and large, so normal distributed by and large. (weak assumption)
(d)
TukeyHSD(aov.model,conf.level = 0.9)
## Tukey multiple comparisons of means
## 90% family-wise confidence level
##
## Fit: aov(formula = obs ~ type, data = dat1)
##
## $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,conf.level = 0.9))

For pair 3-2, p=0.0440578<0.1, so they significant differ using a familywise error rate of \(\alpha\)=0.10.
From the plot, we can see 3-2 pair does not cover 0 within the interval, so this is where difference comes from.