Question 1
Part A
library(pwr)
pwr.anova.test(k=4,n=NULL,f=sqrt(1/sqrt(4.5)),sig.level=0.05,power=0.8)
##
## Balanced one-way analysis of variance power calculation
##
## k = 4
## n = 6.842217
## f = 0.686589
## sig.level = 0.05
## power = 0.8
##
## NOTE: n is number in each group
We need 7 sample for experiment.
Part b
pwr.anova.test(k=4,n=NULL,f=sqrt((0.5)^2/sqrt(4.5)),sig.level=0.05,power=0.8)
##
## Balanced one-way analysis of variance power calculation
##
## k = 4
## n = 24.12736
## f = 0.3432945
## sig.level = 0.05
## power = 0.8
##
## NOTE: n is number in each group
We need 25 sample for study.
Question 2
R1<-c(17.6,18.9,16.3,17.4,20.1,21.6)
R2<-c(16.9,15.3,18.6,17.1,19.5,20.3)
R3<-c(21.4,23.6,19.4,18.5,20.5,22.3)
R4<-c(19.3,21.1,16.9,17.5,18.3,19.8)
dat<-data.frame(R1,R2,R3,R4)
pwr.anova.test(k=4,n=6,f=0.489,sig.level=0.10,power=NULL)
##
## Balanced one-way analysis of variance power calculation
##
## k = 4
## n = 6
## f = 0.489
## sig.level = 0.1
## power = 0.5617031
##
## NOTE: n is number in each group
life<-c(17.6,18.9,16.3,17.4,20.1,21.6,16.9,15.3,18.6,17.1,19.5,20.3,21.4,23.6,19.4,18.5,20.5,22.3,19.3,21.1,16.9,17.5,18.3,19.8)
f_type<-c(1,1,1,1,1,1,2,2,2,2,2,2,3,3,3,3,3,3,4,4,4,4,4,4)
f_type<-as.factor(f_type)
dat<-cbind(life,f_type)
dat<-as.data.frame(dat)
dat.model<-aov(life~f_type)
dat.model
## Call:
## aov(formula = life ~ f_type)
##
## Terms:
## f_type Residuals
## Sum of Squares 30.16500 65.99333
## Deg. of Freedom 3 20
##
## Residual standard error: 1.816498
## Estimated effects may be unbalanced
summary(dat.model)
## Df Sum Sq Mean Sq F value Pr(>F)
## f_type 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
plot(dat.model)
d<-TukeyHSD(dat.model,conf.level = 0.9)
Part aPower should be 0.561
We reject the null hypothesis, P value above greater than 0.0525.