# How to apply Mahalanobis weighted regression in R?

Some research has shown that in linear regression applications the Mahalanobis distance approach can be used to perform regressions that lower the influence of outliers. The idea is that in the regression every observation is given a weight as an inverse of the Mahalanobis distance.

I see that there is a package RLMM for applying Mahalanobis distance in a classification setting. However, I do not see a regression technique that allows one to apply this as a robust regression technique.

My assumption is that I can use the lm() function and specify weights as the inverse of the output of Mahalanobis distance function. Since it seems the Mahalanobis distance function is equivalent to using GLS then can I simply use the gls() function?

A) i assume it'll be computationally more efficient to just:

md<-mahalanobis(x,colMeans(x),var(x))
lm(y~x,weights=sqrt(1/(md+1)))


By the way, $1/(1+\verb+md+)$ (not $1/\verb+md+$) is the quantity that has an interpretation in terms of multivariate extention of Chebyshev's inequality (see Marshall and Olkin (1960). Multivariate Chebyshev inequalities. for a more complete treatment of this)

B) You are wrong to assume that this approach is in any sense robust to outliers. For one thing, some observations can be outlying on the response variable only (which is information the mahalanobis distances don't use) and for another, the mahalanobis distance themselves are sensitive to outliers.

C) Use approaches that are robust to outliers. For example:

library(robust)
lmRob(y~x)

• Good point about the paper. It doesn't even describe robust regression correctly.
– whuber
Aug 4, 2011 at 13:41
• Extremely helpful - thank you. I've removed the link to the paper Aug 4, 2011 at 14:18