question 1(a)

library(pwr)

pwr.anova.test(k=4,n=NULL,f=sqrt((1)^2/4.5),sig.level=0.05,power=0.80)
## 
##      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

No. of samples to be collected is n=14

question 1(b)

library(pwr)

pwr.anova.test(k=4,n=NULL,f=sqrt((.5)^2/4.5),sig.level=0.05,power=0.80)
## 
##      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

No. of samples to be collected is n=50 under this conditions.

Question 2

library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
C<-read.csv("C:/R Activities/Week 4/Homework/9.csv")
colnames(C)<-c("Life","Type")

Question 2 A

library(pwr)
?pwr.anova.test
## starting httpd help server ... done
pwr.anova.test(k=6,n=24,f=sqrt((1)^2/4.18),sig.level=0.1,power=NULL)
## 
##      Balanced one-way analysis of variance power calculation 
## 
##               k = 6
##               n = 24
##               f = 0.489116
##       sig.level = 0.1
##           power = 0.9993311
## 
## NOTE: n is number in each group

The power is power = 0.99 = 99%

Question 2B

Hypothesis H0: M1=M2…=Mi H1:At least one of the M differs.

Test<- aov(Life~Type, data= C)
plot(Test)

## hat values (leverages) are all = 0.1666667
##  and there are no factor predictors; no plot no. 5

Question 2C

From the plot we can see that the spread of the residuals tends to be equal to fitted values

Question 2 D

library(agricolae)
?TukeyHSD
TukeyHSD(Test)
##   Tukey multiple comparisons of means
##     95% family-wise confidence level
## 
## Fit: aov(formula = Life ~ Type, data = C)
## 
## $Type
##             diff         lwr       upr     p adj
## T2-T1 -0.7000000 -3.63540073 2.2354007 0.9080815
## T3-T1  2.3000000 -0.63540073 5.2354007 0.1593262
## T4-T1  0.1666667 -2.76873407 3.1020674 0.9985213
## T3-T2  3.0000000  0.06459927 5.9354007 0.0440578
## T4-T2  0.8666667 -2.06873407 3.8020674 0.8413288
## T4-T3 -2.1333333 -5.06873407 0.8020674 0.2090635
plot(TukeyHSD(Test))

# 0 is include in the interval we cannot Reject H0