In the sample code below I would expect a tree with 3 branches if it was really using centroids. Indeed the 2 closest points are A and B with a distance of 1 < sqrt(5)/2. The centroid of cluster (A,B) is (0.5,0) which is also at a distance 1 from C. But this is not what I am observing.

I know that the Lance-Williams formula is used to compute the distances (Centroid linkage clustering with hclust yields wrong dendrogram?). So the distance between (A,B) and C is 0.5*(sqrt(5)/2) + 0.5*(sqrt(5)/2) - 1/4 = 0.868. But what does it mean and what is the link with centroids ?

Sample code : A <- c(0,0) B <- c(1,0) C <- c(0.5, 1) df <- t(data.frame(A=A, B=B, C=C)) plot(df) hc <- hclust(d = dist(df), method = "centroid") library(ggdendro) p <- ggdendrogram(hc, rotate = FALSE, size = 2) p



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.