Skip to content

Instantly share code, notes, and snippets.

@abikoushi
Created June 22, 2024 08:58
Show Gist options
  • Save abikoushi/58a1e0772969a26a74ff2b640ae418e2 to your computer and use it in GitHub Desktop.
Save abikoushi/58a1e0772969a26a74ff2b640ae418e2 to your computer and use it in GitHub Desktop.
What is the difference between `ward.D` and `ward.D2`?
X <- as.matrix(iris[,-5])
d <- dist(X)
h1 <- hclust(d^2, method = "ward.D")
h2 <- hclust(d, method = "ward.D2")
h1$height <- sqrt(h1$height)
#png("dendro2.png")
par(mfrow=c(1,2))
plot(h1)
plot(h2)
#dev.off()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment