Skip to content

Robust multivariate regression with rlm

2 messages · Bill Venables, Brian Ripley

#
lm works for multivariate responses
rlm does not - check what the help file says about the response.

That's about it, really.

Bill Venables.

-----Original Message-----
From: r-help-bounces at stat.math.ethz.ch
[mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Markku
Mielityinen
Sent: Thursday, 24 March 2005 5:20 PM
To: r-help at stat.math.ethz.ch
Subject: [R] Robust multivariate regression with rlm


Dear Group,

I am having trouble with using rlm on multivariate data sets. When I
call rlm I get 

Error in lm.wfit(x, y, w, method = "qr") : 
        incompatible dimensions

lm on the same data sets seem to work well (see code example). Am I
doing something wrong?

I have already browsed through the forums and google but could not find
any related discussions.

I use Windows XP and R Version 2.0.1  (2004-11-15) (if that makes a
difference).

Example code:
[,1]      [,2]
[1,]  49.10899  45.75513
[2,] 505.92018  48.81037
[3,] 973.30659  50.28478
[4,]  55.99533 508.94504
[5,] 964.96028 513.69579
[6,]  48.25670 975.94972
[7,] 510.21291 967.62767
[8,] 977.12363 978.29216
[,1] [,2]
[1,]   50   50
[2,]  512   50
[3,]  974   50
[4,]   50  512
[5,]  974  512
[6,]   50  974
[7,]  512  974
[8,]  974  974
Call:
lm(formula = My ~ Mx)

Coefficients:
             [,1]       [,2]     
(Intercept)   0.934727   3.918421
Mx1           1.003517  -0.004202
Mx2          -0.002624   0.998155
Error in lm.wfit(x, y, w, method = "qr") : 
        incompatible dimensions
Error in lm.wfit(x, y, w, method = "qr") : 
        incompatible dimensions

Another example (this one seems to work):
Call:
rlm(formula = My ~ Mx)
Converged in 0 iterations

Coefficients:
            [,1] [,2]
(Intercept)    1   -1
Mx1            1    1
Mx2           -1    1

Degrees of freedom: 6 total; 0 residual
Scale estimate: 0

Best regards,
        Markku Mielityinen

______________________________________________
R-help at 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
#
On Thu, 24 Mar 2005 Bill.Venables at csiro.au wrote:

            
Actually lm() works for multiple responses, that is it fits each column of 
the response separately by least squares.  It does not do multivariate 
regression in any real sense.

You can apply rlm to each column of the response, just as lm does. Because 
different outliers will appear in each column, there is no benefit in 
doing the columns in parallel as lm can do.
[...]