R rlm model error: 'x' is singular: singular fits are not implemented in 'rlm'

冷暖自知 提交于 2019-12-23 15:47:13

问题


I have this two lists in R:

y=c(420.5568, 693.6305, 420.5568, 946.9677, 499.1046, 946.9677)
x=c(32, 29, 32, 27, 31, 27)

I'm trying to fit this data to rlm model using this code:

fit_new = (rlm(log(tail(y, 3)) ~ poly( tail(x,3), 2, raw=TRUE )))

The response is this error:

 Error in rlm.default(x, y, weights, method = method, wt.method = wt.method,  : 
'x' is singular: singular fits are not implemented in 'rlm'

回答1:


Wrapping up my earlier comment: there's a problem is with the input data. Namely, there are duplicate pairs (x, y). Regression algorithms usually work on matrices, and if a matrix has identical rows or columns, its' determinant is zero. Some algorithms can take care of that; some don't.

Here's a minimal ad-hoc fix for your data: use unique to remove duplicates. Be careful though: as a general solution, you'll have to remove duplicate pairs, not only duplicates within x and y separately.



来源:https://stackoverflow.com/questions/32906388/r-rlm-model-error-x-is-singular-singular-fits-are-not-implemented-in-rlm

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!