Re: [R] Help with Mahalanobis

From: Thomas Petzoldt <petzoldt_at_rcs.urz.tu-dresden.de>
Date: Thu 14 Jul 2005 - 03:11:17 EST

Hello,

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

http://www.biostat.wustl.edu/archives/html/s-news/2001-07/msg00035.html

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.:

data(iris)

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.



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Thu Jul 14 03:24:24 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:33:38 EST