Rank deficiency when trying to use fitlm
13 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
dpb
el 21 de Mzo. de 2019
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?
Respuestas (1)
Todd Harris
el 9 de Jun. de 2020
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 comentarios
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!