* * Example from section 20.5, page 775 * Two stage least squares * cal 1970 open data table20-2.prn data(format=prn,org=columns) 1970:1 1999:1 * * First stage regression to get fitted value for y1 * linreg y1 # constant x1 x2 prj y1hat * * Second stage regression of y2 on constant and y1-hat * linreg y2 # constant y1hat * * LINREG with the CREATE option will take the coefficients and X'X matrix from * the previous regression, and apply them to a different set of regressors, in * this case, the actual explanatory variable. This will correct the standard * errors by causing the residuals to be computed using y1 rather than y1-hat. * linreg(create) y2 # constant y1 * * This is a direct application of 2SLS, skipping all of the above steps. You set * the list of pre-determined (exogenous) variables with the instruction * INSTRUMENT, then do a LINREG with the actual explanatory variables, and * including the option INSTRUMENTS. * instruments constant x1 x2 linreg(instruments) y2 # constant y1 * * Hausman test for y1 in the y2 regression. This takes as given that x1 and x2 * are predetermined, and uses that to test whether y1 is as well. * * Regress y2 on y1hat (the fitted values from the first stage regression) and * y1-y1hat (the residuals from that regression). The null is that the coefficient * on the latter is 0, which can be tested by looking at the t-statistic in the * regression. * set v = y1-y1hat linreg y2 # constant y1hat v instruments constant x1 x2 linreg y2 # constant y1 set u = %resids linreg u # constant y1 y1hat linreg y2 # constant y1 y1hat linreg y2 # constant y1hat v