Apologies if this is a basic question, but can someone explain what -reg- is doing? I had been assuming that the estimates that -reg- reports are simply the result of matrix multiplication, but that seems not to be the case.
Under what conditions do the estimates reported by -reg- match matrix multiplication? I realize this is an odd hand-picked example, but I'm just trying to understand what -reg- does.
Code:
* make a data setclear set seed 999 set obs 400 gen y = rnormal() gen x1 = ln(_n + 1000) gen x2 = x1^2 gen x3 = x1^3 noi corr * /* yes, all RHS vars are very highly correlated as we'd expect*/ * matrix mult method of getting betas gen con = 1 mkmat con x1 x2 x3 , matrix(x) mkmat y matrix B = inv(x'*x)*(x'*y) matrix list B /* compare this ... */ * ols reg y x1 x2 x3 /* ... with this */
Comment