问题
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