I am performing the multiple factors linear regression in matrix form in MATLAB and I have come across the following warning:
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = smth.
I suspect it is because of the way that I am performing the linear regression, I am following the standard method where the vector of coefficients is ((X'X)^(-1))*(X'Y)
. My matrix X
is of the following format: the first column is just all 1
so that the intercept can be found, in other columns I use powers (so a polynomial basis model) of x
-coordinates, so x
then x^2
, x^3
etc. (column vectors). I think the error arises due to the fact that with higher bases the values are extremely small, and somehow it turns them into NaN
, thus the warning.
I was thinking of using another variable type, but double is as big as it gets? Is there a way then to force MATLAB not to assign those extremely small values to NaN
? If that is of course what MATLAB does.