[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


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)

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

#here is the {robustbase} result
D2rb<- covMcd(x)

[1] 0.7737193 1.1177445 0.7290794 0.6275703 3.5517622 6.0334350 1.0582663
 [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