[R] Robust multivariate regression with rlm

Bill.Venables@csiro.au Bill.Venables at csiro.au
Thu Mar 24 08:52:43 CET 2005


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:

> Mx
          [,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
> My
     [,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
> model<-lm(My~Mx)
> model

Call:
lm(formula = My ~ Mx)

Coefficients:
             [,1]       [,2]     
(Intercept)   0.934727   3.918421
Mx1           1.003517  -0.004202
Mx2          -0.002624   0.998155

> model<-rlm(My~Mx)
Error in lm.wfit(x, y, w, method = "qr") : 
        incompatible dimensions
> model<-rlm(My~Mx,psi=psi.bisquare)
Error in lm.wfit(x, y, w, method = "qr") : 
        incompatible dimensions

Another example (this one seems to work):

> Mx<-matrix(c(0,0,1,0,0,1),ncol=2,byrow=TRUE)+1
> My<-matrix(c(0,0,1,1,-1,1),ncol=2,byrow=TRUE)+1
> model<-rlm(My~Mx)
> model
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




More information about the R-help mailing list