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)
strength <- c(t1,t2,t3,t4)
technique <- c(1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4)
d1 <- cbind(technique,strength)
d1 <- as.data.frame(d1)
d1$technique <- as.factor(d1$technique)
aov.model<-aov(strength~technique,data=d1)
summary(aov.model)
## Df Sum Sq Mean Sq F value Pr(>F)
## technique 3 489740 163247 12.73 0.000489 ***
## Residuals 12 153908 12826
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
t <- 2.179
MSE <- 12826
n = 4
LSD = t*sqrt(2*MSE/n)
library(car)
## Loading required package: carData
scatterplot(strength~technique)
plot(aov.model)
#mu1,mu2,mu3,mu4 all the means are equal of null hypothesis,alternative hypothesis = AT least one mean is different #FROM the result, The only pair of means that we would reject is mu1 and mu3, because the difference in means is less than the LSD #The plot shows the variances are close to each other, that has constant variance
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)
strength <- c(T1,T2,T3,T4,T5)
group <- c(1,1,1,1,1,2,2,2,2,2,3,3,3,3,3,4,4,4,4,4,5,5,5,5,5)
df <- cbind(group,strength)
df <- as.data.frame(df)
df$group <- as.factor(df$group)
aov.model<-aov(strength~group,data=df)
summary(aov.model)
## Df Sum Sq Mean Sq F value Pr(>F)
## group 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,"group",p.adj = "none",console=TRUE)
##
## Study: aov.model ~ "group"
##
## LSD t Test for strength
##
## Mean Square Error: 8.06
##
## group, means and individual ( 95 %) CI
##
## strength 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.
##
## strength groups
## 4 21.6 a
## 3 17.6 b
## 2 15.4 b
## 5 10.8 c
## 1 9.8 c
plot(aov.model)
#mu1,mu2,mu3,mu4 all the means are equal of null hypothesis,alternative hypothesis = AT least one mean is different # The residuals have normal shape, so the variance are equal # we got the normality assumptions and variance assumptions are satisfied and graphs plotted.
library(pwr)
mu1 = 50
mu2 = 60
mu3 = 50
mu4 = 60
v = 25
avg_u = (mu1+mu2+mu3+mu4)/4
pwr.anova.test(k=4,n=NULL,f=sqrt(10^2/v),sig.level=0.05,power=0.90)
##
## Balanced one-way analysis of variance power calculation
##
## k = 4
## n = 2.170367
## f = 2
## sig.level = 0.05
## power = 0.9
##
## NOTE: n is number in each group
#n = 2.170367, so 3 observations are needed from each population
mu1 = 50
mu2 = 60
mu3 = 50
mu4 = 60
v = 36
avg_u = (mu1+mu2+mu3+mu4)/4
pwr.anova.test(k=4,n=NULL,f=sqrt(10^2/v),sig.level=0.05,power=0.90)
##
## Balanced one-way analysis of variance power calculation
##
## k = 4
## n = 2.518782
## f = 1.666667
## sig.level = 0.05
## power = 0.9
##
## NOTE: n is number in each group
v=49
pwr.anova.test(k=4,n=NULL,f=sqrt(10^2/49),sig.level=0.05,power=0.90)
##
## Balanced one-way analysis of variance power calculation
##
## k = 4
## n = 2.939789
## f = 1.428571
## sig.level = 0.05
## power = 0.9
##
## NOTE: n is number in each group
#n = 2.518782, so 3 observations are needed from each population #n = 2.939789, so 3 observations are needed from each population # As the variance incresres the number of samples increases for the samples needed for the possible variance # To estimate standard variance we dont have enough data