1 Problem 1

1.1 Item a

We need 14 observations from each group

library(pwr)
pwr.anova.test(k=4,n=NULL,f=1/sqrt(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

1.2 Item b

We need 51 observations from each group

pwr.anova.test(k=4,n=NULL,f=0.5/sqrt(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

2 Problem 2

Registering the data

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)

2.1 Item a

The power of the test is 0.56

mean(dat$fluid1)
## [1] 18.65
mean(dat$fluid2)
## [1] 17.95
mean(dat$fluid3)
## [1] 20.95
mean(dat$fluid4)
## [1] 18.81667
fluid_sd <- c(fluid1,fluid2,fluid3,fluid4)
sd(fluid_sd)
## [1] 2.0447
pwr.anova.test(k=4,n=6,f=1/2.0447 ,sig.level = 0.1,power=NULL)
## 
##      Balanced one-way analysis of variance power calculation 
## 
##               k = 4
##               n = 6
##               f = 0.4890693
##       sig.level = 0.1
##           power = 0.561814
## 
## NOTE: n is number in each group

2.2 Item b

Since the p-value is less than 0.1, we successfully reject the null hypotheses that the means are equal with 90% confidence

library(tidyr)
dat <- pivot_longer(dat,c(fluid1,fluid2,fluid3,fluid4))
aov.model <- aov(value~name,data=dat)
summary(aov.model)
##             Df Sum Sq Mean Sq F value Pr(>F)  
## name         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

2.3 Item c

The variance seems pretty similar from each population sample. In addition the data seems fairly normal from the qq plot.

plot(aov.model)

2.4 Item D

Except the mean between fluid 2 and 3, all of the means significantly differed. Also from the confidence interval plot we can see that the zero value is not contained in the fluid 2 and 3 comparison

TukeyHSD(aov.model,conf.level = 0.9)
##   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.9))