#=========================================================================== # Zusatzmaterial zu Übungsblatt 9 # Statistik 4 für Nebenfachstudierende # SoSe 2017 # # Datum: 13.07.2017 # Autor: Micha Schneider #============================================================================= ## Aufgabe 18 # data: x <- matrix(c(23,25,46,55,51,100,60,84,34,40),nrow=2) colnames(x) <- c("Person 1","Person 2","Person 3","Person 4","Person 5") rownames(x) <- c("Alter","Einkommen") # euclidean distances: xd <- dist(t(x), method = "euclidean") xd ## Single Linkage # clustering: SL <- hclust(xd, method="single") # plot of dendrogram: plot(SL) # heights: SL$height ## Complete Linkage CL <- hclust(xd, method="complete") plot(CL) CL$height ## Aufgabe 19 # data x <- matrix(c(81.1,64.9,79.6,81,85,1.29,2.97,2.02,2.7,1.33), ncol=2) rownames(x) <- c("Deutschland","Indien","Indonesien","Israel","Japan") colnames(x) <- c("Lebenserwartung","KinderproFrau") x cov(x) # Standardisierung (-> mean = zero, variance = 1) xs <- cbind(scale(x[,1]),scale(x[,2])) (x[,1]-mean(x[,1]))/sqrt(cov(x)[1,1]) # per Hand (x[,2]-mean(x[,2]))/sqrt(cov(x)[2,2]) # euclidean distances: xd <- round(dist(xs),2) round(xd,1) # clustering: CL2 <- hclust(xd, method="complete") plot(CL2, hang=-1) CL2$height