Q1.

#Assume k=4 populations with a constant variance (sigma^2=3.5)

#Min variability (One mean each end of endpoint, rest at midpoint)
power.anova.test(groups=4,n=NULL,between.var=var(c(18,19,19,20)),within.var=3.5,sig.level=0.05,power=0.80)
## 
##      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

n=20.08368,So 21 samples of each fluid will need to be collected to achieve this design criterion in the case of Min variability.

#Intermediate variability (The means are equally spaced) space=(20-18)/3
power.anova.test(groups=4,n=NULL,between.var=var(c(18,18+(20-18)/3,18+(2*(20-18)/3),20)),within.var=3.5,sig.level=0.05,power=0.80)
## 
##      Balanced one-way analysis of variance power calculation 
## 
##          groups = 4
##               n = 18.17867
##     between.var = 0.7407407
##      within.var = 3.5
##       sig.level = 0.05
##           power = 0.8
## 
## NOTE: n is number in each group

n=18.17867,So 19 samples of each fluid will need to be collected to achieve this design criterion in the case of Intermediate variability.

#Max variability (All means are at the endpoints)
power.anova.test(groups=4,n=NULL,between.var=var(c(18,18,20,20)),within.var=3.5,sig.level=0.05,power=0.80)
## 
##      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

n=10.56952,So 11 samples of each fluid will need to be collected to achieve this design criterion in the case of Max variability.

Q2.

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)
library(tidyr)
dat<-data.frame(Fluid1,Fluid2,Fluid3,Fluid4)
dat #data is not tidy 
##   Fluid1 Fluid2 Fluid3 Fluid4
## 1   17.6   16.9   21.4   19.3
## 2   18.9   15.3   23.6   21.1
## 3   16.3   18.6   19.4   16.9
## 4   17.4   17.1   18.5   17.5
## 5   20.1   19.5   20.5   18.3
## 6   21.6   20.3   22.3   19.8
dat<-pivot_longer(dat,c(Fluid1,Fluid2,Fluid3,Fluid4))
dat #data is tidy
## # A tibble: 24 × 2
##    name   value
##    <chr>  <dbl>
##  1 Fluid1  17.6
##  2 Fluid2  16.9
##  3 Fluid3  21.4
##  4 Fluid4  19.3
##  5 Fluid1  18.9
##  6 Fluid2  15.3
##  7 Fluid3  23.6
##  8 Fluid4  21.1
##  9 Fluid1  16.3
## 10 Fluid2  18.6
## # ℹ 14 more rows
aov.model<-aov(value~name,data=dat)
summary(aov.model)
##             Df Sum Sq Mean Sq F value Pr(>F)  
## name         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

p-value=0.0525 less than α=0.10, so reject the H0, there is significant evidence to conclude that at least one fluid mean lifetime differs.

plot(aov.model)

Based on the plots, the residuals show approximately constant variance and normality. Therefore, the ANOVA model appears adequate.

library(car)
## Loading required package: carData
TukeyHSD(aov.model,conf.level=0.90)
##   Tukey multiple comparisons of means
##     90% family-wise confidence level
## 
## Fit: aov(formula = value ~ name, data = dat)
## 
## $name
##                     diff        lwr       upr     p adj
## Fluid2-Fluid1 -0.7000000 -3.2670196 1.8670196 0.9080815
## Fluid3-Fluid1  2.3000000 -0.2670196 4.8670196 0.1593262
## Fluid4-Fluid1  0.1666667 -2.4003529 2.7336862 0.9985213
## Fluid3-Fluid2  3.0000000  0.4329804 5.5670196 0.0440578
## Fluid4-Fluid2  0.8666667 -1.7003529 3.4336862 0.8413288
## Fluid4-Fluid3 -2.1333333 -4.7003529 0.4336862 0.2090635
plot(TukeyHSD(aov.model,conf.level=0.90))

The Fluid 2 and Fluid 3 significantly differ. Because the adjusted p-value ofFluid3-Fluid2 is 0.044, and the 90% CI does not include zero.