Question No: 1
Answer to The Question No: 1.a
library(pwr)
## Warning: package 'pwr' was built under R version 4.1.3
sqrt(1/4.5)
## [1] 0.4714045
pwr.anova.test(k=4,n=NULL,f=0.471,sig.level = 0.05,power =0.80)
##
## Balanced one-way analysis of variance power calculation
##
## k = 4
## n = 13.30502
## f = 0.471
## sig.level = 0.05
## power = 0.8
##
## NOTE: n is number in each group
Answer: The samples of each fluid will need to be collected to achieve this design criterion will be 13.3 ~ 14
Answer to the Question No: 1.b
sqrt(.5^2/4.5)
## [1] 0.2357023
pwr.anova.test(k=4,n=NULL,f=0.2357,sig.level = 0.05,power =0.80)
##
## Balanced one-way analysis of variance power calculation
##
## k = 4
## n = 50.05016
## f = 0.2357
## sig.level = 0.05
## power = 0.8
##
## NOTE: n is number in each group
Answer: so for the variance of 4.5 at 30 minutes we get a sample size of 50.05 ~ 51
Question No: 2
type_1<-c(17.6, 18.9, 16.3, 17.4, 20.1, 21.6)
type_2<-c(16.9, 15.3, 18.6, 17.1, 19.5, 20.3)
type_3<-c(21.4, 23.6, 19.4, 18.5, 20.5, 22.3)
type_4<-c(19.3, 21.1, 16.9, 17.5, 18.3, 19.8)
fluids<-cbind.data.frame(type_1,type_2,type_3,type_4)
sd(c(type_1,type_2,type_3,type_4))
## [1] 2.0447
Answer to the Question No: 2.a
f=(1)^2/(2.0447)^2
f
## [1] 0.2391888
pwr.anova.test(k=4,n=6,f=0.239,sig.level = .1,power =NULL)
##
## Balanced one-way analysis of variance power calculation
##
## k = 4
## n = 6
## f = 0.239
## sig.level = 0.1
## power = 0.2132915
##
## NOTE: n is number in each group
Answer: Power will be 0.2133
Answer to the Question No: 2.b
library(tidyr)
fluid_sample<-pivot_longer(data = fluids, c(type_1,type_2,type_3,type_4))
aov_model<-aov(value~name, data = fluid_sample)
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
Comments: Here we get P-value 0.0525 which is less than 0.1, Hence we reject the null hypothesis
Answer to the Question No: 2.c
plot(aov_model)
## hat values (leverages) are all = 0.1666667
## and there are no factor predictors; no plot no. 5
Comments: Analyze the plots we see in the QQ normality plot it looks normal, as the readings are almost falls on the straight line. So We can conclude that the model is adequate.
Answer to the Question No: 2.d
library(car)
## Warning: package 'car' was built under R version 4.1.3
## Loading required package: carData
aov.model<-aov(value~name,data=fluid_sample)
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
plot(aov.model)
## hat values (leverages) are all = 0.1666667
## and there are no factor predictors; no plot no. 5
TukeyHSD(aov.model,conf.level = 0.90)
## Tukey multiple comparisons of means
## 90% family-wise confidence level
##
## Fit: aov(formula = value ~ name, data = fluid_sample)
##
## $name
## diff lwr upr p adj
## type_2-type_1 -0.7000000 -3.2670196 1.8670196 0.9080815
## type_3-type_1 2.3000000 -0.2670196 4.8670196 0.1593262
## type_4-type_1 0.1666667 -2.4003529 2.7336862 0.9985213
## type_3-type_2 3.0000000 0.4329804 5.5670196 0.0440578
## type_4-type_2 0.8666667 -1.7003529 3.4336862 0.8413288
## type_4-type_3 -2.1333333 -4.7003529 0.4336862 0.2090635
plot(TukeyHSD(aov.model,conf.level = 0.90))
Comments: From the plot only type 2 and 3 differ significantly.