Question 1
## Loading required package: carData
power.anova.test(groups = 4,n = NULL, sig.level = 0.05, power = 0.8, between.var=var(c(18,19,19,20)), within.var = 3.5)
##
## 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
power.anova.test(groups = 4,n = NULL, sig.level = 0.05, power = 0.8, between.var=var(c(18,18.66667,19.3333,20)), within.var=3.5)
##
## Balanced one-way analysis of variance power calculation
##
## groups = 4
## n = 18.17886
## between.var = 0.7407326
## within.var = 3.5
## sig.level = 0.05
## power = 0.8
##
## NOTE: n is number in each group
power.anova.test(groups = 4,n = NULL, sig.level = 0.05, power = 0.8, between.var=var(c(18,18,20,20)), within.var = 3.5)
##
## 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
Comment: The N value required for the Minimum Variance is 21. Intermediate Variance is 19 and Maximum is 11.
Question 2
aov.model <- aov(value~name, data=df)
summary(aov.model)
## Df Sum Sq Mean Sq F value Pr(>F)
## name 3 19.83 6.611 1.373 0.28
## Residuals 20 96.33 4.816
Comment: Fail to reject the hypothesis at an alpha of 0.1
plot(aov.model)
Comment: #The Model appears adequate. There may be one outlier but
nothing to cause major concern.
TukeyHSD(aov.model)
## Tukey multiple comparisons of means
## 95% family-wise confidence level
##
## Fit: aov(formula = value ~ name, data = df)
##
## $name
## diff lwr upr p adj
## dat2-dat1 0.9666667 -2.579757 4.513090 0.8700640
## dat3-dat1 2.3000000 -1.246424 5.846424 0.2956275
## dat4-dat1 0.1666667 -3.379757 3.713090 0.9991586
## dat3-dat2 1.3333333 -2.213090 4.879757 0.7214052
## dat4-dat2 -0.8000000 -4.346424 2.746424 0.9206966
## dat4-dat3 -2.1333333 -5.679757 1.413090 0.3577999
plot(TukeyHSD(aov.model, conf.level = 0.9))
Comment: None of the values differ significantly so none of them will be
rejected
#Complete Code
library(car)
library(agricolae)
library(tidyr)
library(pwr)
?power.anova.test
power.anova.test(groups = 4,n = NULL, sig.level = 0.05, power = 0.8, between.var=var(c(18,19,19,20)), within.var = 3.5)
#20.1
power.anova.test(groups = 4,n = NULL, sig.level = 0.05, power = 0.8, between.var=var(c(18,18.66667,19.3333,20)), within.var=3.5)
#18.2
power.anova.test(groups = 4,n = NULL, sig.level = 0.05, power = 0.8, between.var=var(c(18,18,20,20)), within.var = 3.5)
#10.6
#2
dat1 <- c(17.6,18.9,16.3,17.4,20.1,21.6)
dat2 <- c(16.9,25.3,18.6,17.1,19.5,20.3)
dat3 <- c(21.4,23.6,19.4,18.5,20.5,22.3)
dat4 <- c(19.3,21.1,16.9,17.5,18.3,19.8)
df <- data.frame(dat1,dat2,dat3,dat4)
df <- pivot_longer(df, c(dat1,dat2,dat3,dat4))
df$name <- as.factor(df$name)
aov.model <- aov(value~name, data=df)
summary(aov.model)
#Fail to reject the hypothesis at an alpha of 0.1
plot(aov.model)
#The Model appears adequate. There may be one outlier but nothing to cause major concern.
TukeyHSD(aov.model)
plot(TukeyHSD(aov.model, conf.level = 0.9))