Just to add to the other comments: you almost never want to invert the X'X matrix. (Which is k by k, where k is the number of regressors.) The QR decomposition is much more reliable. (for those that want a citation: Seber and Lee's Linear regression analysis is great.)