# [R] Robust multivariate regression with rlm

From: Markku Mielityinen <mmmm_at_st.jyu.fi>
Date: Thu 24 Mar 2005 - 18:19:48 EST

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.

Example code:

> Mx

[,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@stat.math.ethz.ch mailing list