Rank deficiency when trying to use fitlm

10 次查看(过去 30 天)
I am trying to fit a simple regression model to some data (y ~ 1 + x1). However, I am not getting an estimate for the y-intercept because my design matrix is rank-deficient (Note: Xs and Ys are large column vectors, 4502342x1):
>> fitlm(Xs,Ys)
Warning: Regression design matrix is rank deficient to within machine precision.
> In classreg.regr.CompactTermsRegression/checkDesignRank (line 35)
In LinearModel.fit (line 1236)
In fitlm (line 121)
ans =
Linear regression model:
y ~ 1 + x1
Estimated Coefficients:
Estimate SE tStat pValue
________ _________ _______ ______
(Intercept) 0 0 NaN NaN
x1 -0.64712 0.0041947 -154.27 0
Number of observations: 3129429, Error degrees of freedom: 3129428
Root Mean Squared Error: 39.3
R-squared: 0.0852, Adjusted R-Squared 0.0852
F-statistic vs. constant model: Inf, p-value = NaN
I tried researching what rank deficiency means in this context, but didn't have much luck. When I take a subset of the data, e.g.:
rsam = randsample(length(Xs),round( length(Xs) / 100 ));
fitlm(Xs(rsam),Ys(rsam))
I have absolutely no trouble at all; output is great. Can anyone shed some light on this?
  4 个评论
dpb
dpb 2019-3-21
OK, if it isn't related to not showing what actually generated the error, then the full vector contains data that are linear combinations of others. What does
rank(Xs)
return?

请先登录,再进行评论。

回答(1 个)

Todd Harris
Todd Harris 2020-6-9
I was having this problem but managed to solve it by converting the input for the fitlm function to double (they were single originally). Hope this helps.

类别

Help CenterFile Exchange 中查找有关 Dimensionality Reduction and Feature Extraction 的更多信息

产品


版本

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by