library(pwr)
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
# Ans to the ques 1.(a).
# 14 samples of each fluid we will need to be collected
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
# Ans to the ques 1.(b).
# 51 samples of each fluid we will need to be collected
type1 <- c(17.6, 18.9, 16.3, 17.4, 20.1, 21.6)
type2 <- c(16.9, 15.3, 18.6, 17.1, 19.5, 20.3)
type3 <- c(21.4, 23.6, 19.4, 18.5, 20.5, 22.3)
type4 <- c(19.3, 21.1, 16.9, 17.5, 18.3, 19.8)
dat <- data.frame(type1,type2,type3,type4)
f <- (1)^2/(2.0447)^2
pwr.anova.test(k=4,n=6,f,sig.level = .1,power =NULL)
##
## Balanced one-way analysis of variance power calculation
##
## k = 4
## n = 6
## f = 0.2391888
## sig.level = 0.1
## power = 0.213476
##
## NOTE: n is number in each group
# Ans to the ques 2.(a).
# The power will be 0.213476 for a hypothesis test with an alpha = 0.10 level
# of significance
library(tidyr)
fluidsample<-pivot_longer(data = dat, c(type1,type2,type3,type4))
aov.model<-aov(value~name, data = fluidsample)
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
# Ans to the ques 2.(b).
# Since p value = 0.0525 is less than alpha = 0.1, so we reject null hypothesis.
plot(aov.model)
## hat values (leverages) are all = 0.1666667
## and there are no factor predictors; no plot no. 5
# Ans to the ques 2.(c).
# From the plot, it seems like Normality assumption is satisfied.
# The model is adequate.
TukeyHSD(aov.model, conf.level = 0.9)
## Tukey multiple comparisons of means
## 90% family-wise confidence level
##
## Fit: aov(formula = value ~ name, data = fluidsample)
##
## $name
## diff lwr upr p adj
## type2-type1 -0.7000000 -3.2670196 1.8670196 0.9080815
## type3-type1 2.3000000 -0.2670196 4.8670196 0.1593262
## type4-type1 0.1666667 -2.4003529 2.7336862 0.9985213
## type3-type2 3.0000000 0.4329804 5.5670196 0.0440578
## type4-type2 0.8666667 -1.7003529 3.4336862 0.8413288
## type4-type3 -2.1333333 -4.7003529 0.4336862 0.2090635
plot(TukeyHSD(aov.model, conf.level = 0.9))
# Ans to the ques 2.(d).
# Type 2 and Type 3 fluid significantly differs
Source Code
library(pwr)
sqrt(1/4.5)
pwr.anova.test(k=4,n=NULL,f=0.471,sig.level = 0.05,power =0.80)
sqrt(.5^2/4.5)
pwr.anova.test(k=4,n=NULL,f=0.2357,sig.level = 0.05,power =0.80)
type1 <- c(17.6, 18.9, 16.3, 17.4, 20.1, 21.6)
type2 <- c(16.9, 15.3, 18.6, 17.1, 19.5, 20.3)
type3 <- c(21.4, 23.6, 19.4, 18.5, 20.5, 22.3)
type4 <- c(19.3, 21.1, 16.9, 17.5, 18.3, 19.8)
dat <- data.frame(type1,type2,type3,type4)
f <- (1)^2/(2.0447)^2
pwr.anova.test(k=4,n=6,f,sig.level = .1,power =NULL)
library(tidyr)
fluidsample<-pivot_longer(data = dat, c(type1,type2,type3,type4))
aov.model<-aov(value~name, data = fluidsample)
summary(aov.model)
plot(aov.model)
TukeyHSD(aov.model, conf.level = 0.9)
plot(TukeyHSD(aov.model, conf.level = 0.9))