Rank deficiency when trying to use fitlm
13 ビュー (過去 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
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
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.
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!