Linear regression returns NaN for one of five regressors
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentario
Respuestas (1)
Torsten
el 19 de Mayo de 2022
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.
Ver también
Categorías
Más información sobre Linear Regression en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!