[R] How to: Compare Two dendrograms (Hierarchical Clusterings) ?

Ricardo Marcacini ricardo at insigma.com.br
Fri Feb 26 13:09:24 CET 2010


Hi,

To compare two dendrogamas, you can use a measure of correlation between the
cophenetic matrices. Example:

mdist <- dist(iris[,-5], method="euclidean")
# dendrogram from cluster 1 (single-linkage)
hc1 <- hclust(mdist, method="single")
plot(hc1)

# dendrogram from cluster 2 (complete-linkage)
hc2 <- hclust(mdist, method="complete")
plot(hc2)

# correlation
cor(cophenetic(hc1),cophenetic(hc2))

For a confidence level, use the "Mantel Test" from package vegan.

mantel(cophenetic(hc1), cophenetic(hc2))

Good Look.



More information about the R-help mailing list