The linear effect equation is:
x_ij=mu+T_i+E_ij
Hypothesis: H_0 = T_1=T_2=T_3=T_4
Alternative Hypothesis: At least one is different
em1<-c(.34,.12,1.23,.70,1.75,.12)
em2<-c(.91,2.94,2.14,2.36,2.86,4.55)
em3<-c(6.31,8.37,9.75,6.09,9.82,7.24)
em4<-c(17.15,11.82,10.97,17.20,14.35,16.82)
dat<-data.frame(em1,em2,em3,em4)
dat
## em1 em2 em3 em4
## 1 0.34 0.91 6.31 17.15
## 2 0.12 2.94 8.37 11.82
## 3 1.23 2.14 9.75 10.97
## 4 0.70 2.36 6.09 17.20
## 5 1.75 2.86 9.82 14.35
## 6 0.12 4.55 7.24 16.82
response<-c(em1,em2,em3,em4)
factor<-c(rep(1,6),rep(2,6),rep(3,6),rep(4,6))
boxplot(response~factor)
Data found from the box plot above shows that the data is not normally distributed, and the variance is not constant.
model<-aov(response~factor,data=dat)
summary(model)
## Df Sum Sq Mean Sq F value Pr(>F)
## factor 1 672.0 672.0 149.9 2.7e-11 ***
## Residuals 22 98.6 4.5
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
plot(model)
The residuals show that the plot has issues with the constant variances.
library(MASS)
boxcox(response~factor, data=dat)
trans_response<-(sqrt(response)-1)/.5
df<-data.frame(trans_response, factor)
model<-aov(trans_response~factor, data=df)
summary(model)
## Df Sum Sq Mean Sq F value Pr(>F)
## factor 1 130.1 130.12 251.2 1.62e-13 ***
## Residuals 22 11.4 0.52
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
plot(model)
#The box-cox plot shows lambda as 0.5, and failed to reject H_0. No significant difference found
kruskal.test(response~factor, data=dat)
##
## Kruskal-Wallis rank sum test
##
## data: response by factor
## Kruskal-Wallis chi-squared = 21.156, df = 3, p-value = 9.771e-05
The p-value is small (9.771e-05) and rejects H_0 with an Alpha=0.05 level of significance.
em1<-c(.34,.12,1.23,.70,1.75,.12)
em2<-c(.91,2.94,2.14,2.36,2.86,4.55)
em3<-c(6.31,8.37,9.75,6.09,9.82,7.24)
em4<-c(17.15,11.82,10.97,17.20,14.35,16.82)
dat<-data.frame(em1,em2,em3,em4)
dat
response<-c(em1,em2,em3,em4)
factor<-c(rep(1,6),rep(2,6),rep(3,6),rep(4,6))
boxplot(response~factor)
model<-aov(response~factor,data=dat)
summary(model)
plot(model)
library(MASS)
boxcox(response~factor, data=dat)
trans_response<-(sqrt(response)-1)/.5
df<-data.frame(trans_response, factor)
model<-aov(trans_response~factor, data=df)
summary(model)
plot(model)
kruskal.test(response~factor, data=dat)