0

I got this error message from a robust regression in r ; "'x' is singular: singular fits are not implemented in 'rlm'"

I could solve it by removing some variables.

My question is , can i progrom r to solve it on it's own ? so i will not have to remove variables to solve it.

kn.fred
  • 11
  • 2
    'How to program it' is off topic here. FWIW, the "'x' is singular' means you have multicollinearity. – gung - Reinstate Monica Nov 16 '15 at 12:46
  • Simple solution: use the output of lm to find the variables it dropped. Unless rlm is reweighting a relatively large number of observations to zero (which would be hard to do), this will do the trick. – whuber Jul 29 '20 at 15:24

2 Answers2

2

I have come across the same issue with rlm() when an x (predictor) variable is coded as a factor with empty levels (for example, factor(c("a", "b"), levels=c("a","b", "c" ))). Simply converting the factor to a character vector solved my issue. Alternatively, one can use forcats::fct_drop().

CoderGuy123
  • 437
  • 4
  • 14
Jing Xue
  • 121
0

Check for NA values, multicollinearity and duplicate observations. multicollinearity For duplicate observations use jitter rnorm() as suggested: Cause of singularity in matrix for quantile regression.

ran8
  • 157