[R] puzzling classical Mahalanobis distances from covMcd() {robustbase}

Fraser D. Neiman fn9r at cms.mail.virginia.edu
Fri Jul 27 14:15:57 CEST 2012


Greetings,

I am puzzled about why the _classical_ Mahalanobis distances that I get using
the {stats} mahalanobis() function do not match the distances I get from the
{robustbase} covMcd() function. Here is an example:

x <- matrix(rnorm(10*3), ncol = 3)

#here is the {stats} result:
Sx <- cov(x)
D2 <- mahalanobis(x, colMeans(x), Sx)
D2

[1] 1.5135795 1.3761046 1.0367444 1.8111585 4.3038621 5.3195918 3.2798665
5.7559301
 [9] 2.2172150 0.3859475

 
#here is the {robustbase} result
Library(robustbase)
D2rb<- covMcd(x)
D2rb$raw.mah

[1] 0.7737193 1.1177445 0.7290794 0.6275703 3.5517622 6.0334350 1.0582663
5.7169250
 [9] 0.9420184 0.4210470

According to the help file for covMcd{robustbase}

raw.mah	mahalanobis distances of the observations based on the raw estimate of
the location and scatter.

So I think the second set of numbers should match the first. But they do not.
What am I missing here?

Thanks, Fraser



More information about the R-help mailing list