2

I am using Matlab to estimate a regression model with ordinary least squares (OLS).

The model is y = xB, where x is a very sparse matrix with dimension 500000 x 2500. I'm using a QR decomposition:

[C,R] = qr(x,y,0)

and then estimating b with

b = R\C

My question is whether I need to be worried about numerical errors here. Is there some additional iteration I need to do? Should I check the condition number of R, or R'R? Any guidance would be much appreciated.

itzy
  • 11,275
  • 15
  • 63
  • 96

1 Answers1

0

The matlab recommended way is:

b = X\y;

Check http://www.mathworks.com/help/matlab/ref/mldivide.html and section More About in particular, to see how matlab handles different cases under the hood.

If you want to exploit the sparseness of X simply declare X as sparse, X = sparse(X), before the call \.

Jim
  • 256
  • 5
  • 16