Reputation: 4664
I'm using an rlm model like this.
fit=rlm(log(y) ~ x + z)
Z is a list that contains all 1
. I get the error Error in rlm.default(x, y, weights, method = method, wt.method = wt.method, : 'x' is singular: singular fits are not implemented in 'rlm'
Is it equivalent to use fit=rlm(log(y) ~ x + 1)
instead?
Upvotes: 2
Views: 413
Reputation: 48241
Yes, it is equivalent to using rlm(log(y) ~ x + 1)
and actually it is best just to use just rlm(log(y) ~ x)
because the intercept or the constant term (which is the variable containing only 1's) is included by default.
By writing + 1
you just "remind" rlm
that you want the constant term in your regression, whereas writing + z
looks more like you have some variable that you want to add (and you might be unaware that it contains only 1's), but having both the default intercept and such a z
that contains only 1's causes a problem - perfect collinearity, hence this gives an error.
It is strongly advised to always have the intercept in your regression, but if you really wanted to eliminate it, this could be done with log(y) ~ x - 1
. Now actually log(y) ~ x - 1 + z
works fine because there are no two identical variables.
Upvotes: 3