y <- c(36,33,35,34,32,34, 35,37,36,35,37,36, 35,39,37,38,39,38, 34,31,35,32,34,33) condition <- c(rep("type_1", 6), rep("type_2", 6), rep("type_3", 6), rep("type_4", 6)) boxplot(y ~ condition, xlab="触媒", ylab="生産量") summary(aov(y ~ condition)) # 全体平均 grand <- mean(y) # データ行列 data_mat <- matrix(y, nrow=6, ncol=4) grand_mat <- matrix(rep(grand, 24), nrow=6, ncol=4) colmean_mat <- matrix(rep(colMeans(data_mat),6), nrow=6, ncol=4, byrow=T) effect_mat <- colmean_mat - grand_mat error_mat <- data_mat - grand_mat - effect_mat # データ行列の分解を確認する # data_mat = grand_mat + effect_mat + error_mat SS <- sum((data_mat - grand_mat)^2) SS_between <- sum(effect_mat^2) SS_within <- sum(error_mat^2) # 平方和の分解を確認する # SS = SS_between + SS_within # イータ2乗を求める eta2 <- SS_between / SS