library("ClustOfVar") library("FactoMineR") #4.1 First example : Quantitative data data("decathlon") head(decathlon[,1:4]) pca <- PCA(decathlon[,1:10],graph=FALSE) plot(pca, choix="var") tree <- hclustvar(decathlon[,1:10],sim=TRUE) plot(tree) stab <- stability(tree,B=40) plot(stab, main="Stability of the partitions") boxplot(stab$matCR, main="Dispersion of the adjusted Rand index") P3<-cutreevar(tree,3,matsim=TRUE) cluster <- P3$cluster X <- decathlon[,1:10] princomp(X[,which(cluster==1)],cor=TRUE)$sdev^2 princomp(X[,which(cluster==2)],cor=TRUE)$sdev^2 princomp(X[,which(cluster==3)],cor=TRUE)$sdev^2 print(P3) round(P3$sim$cluster1,digit=2) P3$cluster P3$var head(P3$scores) #4.2 Second example: A mixture of quantitative and qualitative data data("wine") head(wine[,1:4]) X.quanti <- wine[,3:29] X.quali <- wine[,1:2] tree <- hclustvar(X.quanti,X.quali) plot(tree) part_hier <- cutreevar(tree,6) part_hier$var$cluster1 print(part_hier) summary(part_hier) part_km<-kmeansvar(X.quanti,X.quali,init=6,nstart=10) part_km$E part_hier$E