anova
5 years ago in R
M1 = structure(c(0, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0, 0.8, 0.8, 0.8,
0.6, 0.8, 0.8, 0, 0.6, 0.6, 0.8, 0.8, 0.8, 0.6, 0, 0, 0.8, 0.8,
0.8, 0.6, 0, 0, 0.8, 0.8, 0.6, 0.8, 0.8, 0.8, 0), .Dim = c(6L,
6L), .Dimnames = list(c("1", "2", "3", "4", "5", "6"), c("1",
"2", "3", "4", "5", "6")))
M2 = structure(c(0, 0.2, 0.5, 0.9, 0.9, 0.2, 0, 0.5, 0.9, 0.9, 0.5,
0.5, 0, 0.9, 0.9, 0.9, 0.9, 0.9, 0, 0.8, 0.9, 0.9, 0.9, 0.8,
0), .Dim = c(5L, 5L), .Dimnames = list(c("1", "2", "3", "4",
"5"), c("1", "2", "3", "4", "5")))
# HISTROGRAM
par(mfrow=c(1,2))
hist(M1, xlab = "")
hist(M2,xlab = "")
# DATAFRAME FROM MATRICES
data_aux1 <- as.data.frame(as.vector(M1))
data_aux1$group <- 1
colnames(data_aux1)=c("obs","group")
data_aux2 <- as.data.frame(as.vector(M2))
data_aux2$group <- 2
colnames(data_aux2)=c("obs","group")
data <- rbind(data_aux1, data_aux2)
# COMPUTE ANOVA
anova_test <- aov(obs ~ group, data = data)
# SUMMARY OF RESULTS
summary(anova_test)