# (1) v3 <- read.delim("http://minato.sip21c.org/advanced-statistics/v3hw.txt", stringsAsFactors=TRUE) plot(WEIGHT ~ HEIGHT, data=v3) coplot(WEIGHT ~ HEIGHT | VG, data=v3) # (2) plot(WEIGHT ~ HEIGHT, data=v3, pch=as.character(VG), col=as.integer(VG), main="3村落住民の身長と体重の関係", xlab="身長(cm)",ylab="体重(kg)") # (3) plot(WEIGHT ~ HEIGHT, data=v3, pch=as.integer(VG), col=as.integer(VG), main="3村落住民の身長と体重の関係", xlab="身長(cm)",ylab="体重(kg)") series <- 1:length(levels(v3$VG)) legend("topleft", pch=series, col=series, legend=levels(v3$VG)) # (4) library(car) dataEllipse(v3$HEIGHT, v3$WEIGHT, v3$VG, levels=0.8) library(Hotelling) Z <- split(v3[,c("HEIGHT","WEIGHT")], v3[,"VG"]) res12 <- hotelling.test(Z[[1]], Z[[2]]) res23 <- hotelling.test(Z[[2]], Z[[3]]) res31 <- hotelling.test(Z[[3]], Z[[1]]) res <- c(res12$pval, res23$pval, res31$pval) names(res) <- c("X-Y", "Y-Z", "Z-X") sort(res)*3:1 # Holm の方法で検定の多重性を補正