フィルターのクリア

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 件のコメント
Star Strider
Star Strider 2022 年 5 月 19 日
The file refuses to load and crashes MATLAB (R2022a).

サインインしてコメントする。

回答 (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.
  1 件のコメント
Sascha Frölich
Sascha Frölich 2022 年 5 月 19 日
Yes that makes total sense, thank you!

サインインしてコメントする。

製品

Community Treasure Hunt

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

Start Hunting!

Translated by