library(agricolae)
t1 <- c(3129,3000,2865,2890)
t2 <- c(3200,3300,2975,3150)
t3 <- c(2800,2900,2985,3050)
t4 <- c(2600,2700,2600,2765)
ts<- c(t1,t2,t3,t4)
t <- c(rep(1,4),rep(2,4),rep(3,4),rep(4,4))
d <- cbind(t,ts)
d <- as.data.frame(d)
d$t <- as.factor(d$t)
aov.model<-aov(ts~t,data=d)
plot(aov.model)

summary(aov.model)
##             Df Sum Sq Mean Sq F value   Pr(>F)    
## t            3 489740  163247   12.73 0.000489 ***
## Residuals   12 153908   12826                     
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
library(agricolae)
l <- LSD.test(aov.model,"t",console = TRUE)
## 
## Study: aov.model ~ "t"
## 
## LSD t Test for ts 
## 
## Mean Square Error:  12825.69 
## 
## t,  means and individual ( 95 %) CI
## 
##        ts       std r      LCL      UCL  Min  Max
## 1 2971.00 120.55704 4 2847.624 3094.376 2865 3129
## 2 3156.25 135.97641 4 3032.874 3279.626 2975 3300
## 3 2933.75 108.27242 4 2810.374 3057.126 2800 3050
## 4 2666.25  80.97067 4 2542.874 2789.626 2600 2765
## 
## Alpha: 0.05 ; DF Error: 12
## Critical Value of t: 2.178813 
## 
## least Significant Difference: 174.4798 
## 
## Treatments with the same letter are not significantly different.
## 
##        ts groups
## 2 3156.25      a
## 1 2971.00      b
## 3 2933.75      b
## 4 2666.25      c
plot(LSD.test(aov.model,"t"))

library(car)
## Loading required package: carData
scatterplot(ts~t,data=d)

#### (c)by using LSD the mean t1 and t2 differes gradter than 174. t2 and t3 is less than 174. #### (d)the probability plot is normally distributed. #### (e)variance are equal.

question 2 (3.10)

t1 <- c(7,7,15,11,9)
t2 <- c(12,17,12,18,18)
t3 <- c(14,19,19,18,18)
t4 <- c(19,25,22,19,23)
t5 <- c(7,10,11,15,11)
ts <- c(t1,t2,t3,t4,t5)
t <- c(rep(1,5),rep(2,5),rep(3,5),rep(4,5),rep(5,5))
d <- cbind(t,ts)
d <- as.data.frame(d)
d$t <- as.factor(d$t)
aov.model<-aov(ts~t,data=d)
summary(aov.model)
##             Df Sum Sq Mean Sq F value   Pr(>F)    
## t            4  475.8  118.94   14.76 9.13e-06 ***
## Residuals   20  161.2    8.06                     
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
library(agricolae)
LSD.test(aov.model,"t",p.adj = "none",console=TRUE)
## 
## Study: aov.model ~ "t"
## 
## LSD t Test for ts 
## 
## Mean Square Error:  8.06 
## 
## t,  means and individual ( 95 %) CI
## 
##     ts      std r       LCL      UCL Min Max
## 1  9.8 3.346640 5  7.151566 12.44843   7  15
## 2 15.4 3.130495 5 12.751566 18.04843  12  18
## 3 17.6 2.073644 5 14.951566 20.24843  14  19
## 4 21.6 2.607681 5 18.951566 24.24843  19  25
## 5 10.8 2.863564 5  8.151566 13.44843   7  15
## 
## Alpha: 0.05 ; DF Error: 20
## Critical Value of t: 2.085963 
## 
## least Significant Difference: 3.745452 
## 
## Treatments with the same letter are not significantly different.
## 
##     ts groups
## 4 21.6      a
## 3 17.6      b
## 2 15.4      b
## 5 10.8      c
## 1  9.8      c
plot(aov.model)

#### by using lsd the t1 and t2 differs grater then 3.74 whereas t2 & t3 is less than 3.74 #### our data satusfies normality and also have constant varience from graph

question 3 (3.44)

library(pwr)
m1 = 50
m2 = 60
m3 = 50   
m4 = 60
varience = 25  
m_avg = (m1+m2+m3+m4)/4  
pwr.anova.test(k=4,n=NULL,f=5/sqrt(varience),sig.level=0.05,power=0.90)
## 
##      Balanced one-way analysis of variance power calculation 
## 
##               k = 4
##               n = 4.658119
##               f = 1
##       sig.level = 0.05
##           power = 0.9
## 
## NOTE: n is number in each group

####n=4.65 rounding off it is 5 observation needed for each population. ### question (3.45)

m1 = 50
m2 = 60
m3 = 50
m4 =60
varience = 36  
m_avg = (m1+m2+m3+m4)/4  
pwr.anova.test(k=4,n=NULL,f=5/sqrt(36),sig.level=0.05,power=0.90)
## 
##      Balanced one-way analysis of variance power calculation 
## 
##               k = 4
##               n = 6.180857
##               f = 0.8333333
##       sig.level = 0.05
##           power = 0.9
## 
## NOTE: n is number in each group
varience = 49
pwr.anova.test(k=4,n=NULL,f=5/sqrt(49),sig.level=0.05,power=0.90)
## 
##      Balanced one-way analysis of variance power calculation 
## 
##               k = 4
##               n = 7.998751
##               f = 0.7142857
##       sig.level = 0.05
##           power = 0.9
## 
## NOTE: n is number in each group

n=6.18 for varience=36 need 7 observations for each populations

n=7.99 for varience=49 need 8 observations for each populations

increase in varience made sample size increase as shown above.

if we dont have varience then we need to assume number of sample to conduct experiment.we can assume sample size to get of varience.