[R] Help with Mahalanobis

Thomas Petzoldt petzoldt at rcs.urz.tu-dresden.de
Wed Jul 13 19:11:17 CEST 2005


a proposed solution of Bill Venables is archieved on the S-News mailing


and if I remember it correctly (and if the variance matrix is estimated
from the data), another similar way is simply to use the Euclidean
distance of rescaled scores of a pricipal component analysis, e.g.:


dat <- iris[1:4] # without the species names

z <- svd(scale(dat, scale=FALSE))$u
cl <- hclust(dist(z), method="ward")
plot(cl, labels=iris$Species)

#### or alternatively: ####

pc <- princomp(dat, cor=FALSE)

pcdata <- as.data.frame(scale(pc$scores))
cl <- hclust(dist(pcdata), method="ward")
plot(cl, labels=iris$Species)

Hope it helps!

Thomas P.

More information about the R-help mailing list