Regression design matrix is rank deficient to within machine precision. How do I interpret this error?
조회 수: 83 (최근 30일)
이전 댓글 표시
I tried using Linear Regresssion commant regress on my train and test data and I am getting a warning saing 'X is rank deficient to within machine precision'. I am not able to interpret the error.
댓글 수: 0
채택된 답변
Star Strider
2020년 3월 6일
It means that at least one of the columns in the design matrix is close to being all zeros.
Without knowing more, one way to avoid that could be to re-scale all the variables (independent and dependent) to some larger values. Re-scaling them could mean adding a constant value to all of them. This would need to be done with caution, since it would be possible to end up with useless results.
댓글 수: 4
Sascha Frölich
2022년 5월 19일
편집: Sascha Frölich
2022년 5월 19일
Hey, I get the same error, and no matter what large values I add to my design matrix (to the point that every value is way beyond zero), the error persists. Why could that be?
Nevermind I just figured it out; I had included a constant regressor, while MATLAB includes an intercept term by itself, so my design matrix was redundant. Cheers!
Star Strider
2022년 5월 19일
One possibility is that one or more columns of the design matrix are linearly dependent.
x = randn(5,1);
DM = [x x+eps ones(size(x))];
y = randn(5,1);
B = DM \ y
Here, the first and second columns of ‘DM’ are liniearly dependent withiin machine tolerance.
.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Linear and Nonlinear Regression에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!