Rank deficiency when trying to use fitlm

조회 수: 17 (최근 30일)
ohmstead
ohmstead 2019년 3월 20일
답변: Todd Harris 2020년 6월 9일
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?
ohmstead
ohmstead 2019년 3월 21일
>> rank(Xs)
ans =
1

댓글을 달려면 로그인하십시오.

답변 (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