问题描述
我在R中有这两个列表:
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)
我正在尝试使用以下代码将此数据调整为rlm
模型:
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 )))
响应是以下错误:
Error in rlm.default(x, y, weights, method = method, wt.method = wt.method, :
'x' is singular: singular fits are not implemented in 'rlm'
推荐答案
总结我先前的评论:输入数据存在问题.即,存在重复的对(x, y)
.回归算法通常适用于矩阵,并且如果矩阵具有相同的行或列,则其行列式为零.一些算法可以解决这个问题.有些没有.
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.
这是针对您数据的最小临时修复:使用unique
删除重复项.不过请注意:作为一般解决方案,您必须删除重复的对,而不仅要分别删除x
和y
中的重复项.
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.
这篇关于R rlm模型错误:"x"为奇数:"rlm"中未实现奇异拟合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!