필터 지우기
필터 지우기

Linear regression returns NaN for one of five regressors

조회 수: 5 (최근 30일)
Sascha Frölich
Sascha Frölich 2022년 5월 19일
댓글: Sascha Frölich 2022년 5월 19일
Hi,
I am trying to perform a linear regression model in MATLAB R2019a on the data as attached using the following command:
lm = fitlm(x,y)
The regression works fine for all but one regressor (see below). There is no linear dependence in the design matrix, although I do get the warning "Regression design matrix is rank deficient to within machine precision." I don't understand where this warning comes from. What's wrong? Any help is greatly appreciated!
Linear regression model:
y ~ 1 + x1 + x2 + x3 + x4 + x5
Estimated Coefficients:
Estimate SE tStat pValue
________ ______ _______ ___________
(Intercept) 414.36 3.703 111.9 1.0822e-300
x1 2.2506 4.244 0.5303 0.5962
x2 -48.916 5.0516 -9.6833 4.9268e-20
x3 -43.883 5.0516 -8.687 1.0056e-16
x4 0 0 NaN NaN
x5 -46.96 5.0516 -9.2961 1.0126e-18

답변 (1개)

Torsten
Torsten 2022년 5월 19일
Adding columns 2,3,4 and 5 shows that the rank of the matrix
[ones(size(x,1),1),x];
will be the same as the rank of x, namely 5, not 6.
Thus you can work with intercept, but you must drop one of the independent variables x2, x3, x4 or x5.

제품

Community Treasure Hunt

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

Start Hunting!

Translated by