k <- 4
sigma2 <- 3.5
# min variability: one mean at each endpoint, others near the middle
# pattern like (18, 19, 19, 20) so range = 2 hours
means_min <- c(18, 19, 19, 20)
out_min <- stats::power.anova.test(groups = k, n = NULL,
between.var = var(means_min),
within.var = sigma2,
sig.level = 0.05, power = 0.80)
out_min
##
## 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
# intermediate variability: equally spaced means across the 2-hr range
# (18.00, 18.67, 19.33, 20.00)
means_mid <- c(18.00, 18.67, 19.33, 20.00)
out_mid <- stats::power.anova.test(groups = k, n = NULL,
between.var = var(means_mid),
within.var = sigma2,
sig.level = 0.05, power = 0.80)
out_mid
##
## Balanced one-way analysis of variance power calculation
##
## groups = 4
## n = 18.21285
## between.var = 0.7392667
## within.var = 3.5
## sig.level = 0.05
## power = 0.8
##
## NOTE: n is number in each group
# max variability: all means at the endpoints
# (18, 18, 20, 20)
means_max <- c(18, 18, 20, 20)
out_max <- stats::power.anova.test(groups = k, n = NULL,
between.var = var(means_max),
within.var = sigma2,
sig.level = 0.05, power = 0.80)
out_max
##
## 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
Min = 21 samples per fluid Mid = 19 samples per fluid Max = 11 samples per fluid
h0: μ1 = μ2 = μ3 = μ4
ha: at least one mean is different
dat <- data.frame(Fluid = factor(rep(1:4, each = 6)),
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))
fit <- aov(Life ~ Fluid, data = dat)
summary(fit)
## Df Sum Sq Mean Sq F value Pr(>F)
## Fluid 3 30.16 10.05 3.047 0.0525 .
## Residuals 20 65.99 3.30
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
p = 0.0525. Since p < 0.10, I reject H0. There is evidence that at least one fluid mean life is different.
par(mfrow = c(2,2))
plot(fit) # residuals vs fitted, qq, scale-location, residuals vs leverage
par(mfrow = c(1,1))
The diagnostic plots look fine.
Residuals are random, normality is ok, and variance looks equal.
The anova model is appropriate for this data.
tk <- TukeyHSD(fit, conf.level = 0.90)
tk
## Tukey multiple comparisons of means
## 90% family-wise confidence level
##
## Fit: aov(formula = Life ~ Fluid, data = dat)
##
## $Fluid
## 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
Only the pair 3 – 2 is significant (p = 0.044 < 0.10).
All other pairs are not significant because their p-values are ≥ 0.10
and the confidence intervals include 0.
This means fluid 3 has a higher average life than fluid 2, but the rest
of the fluids are about the same.
Overall this agrees with the anova result that at least one mean
differs.