options crt; ? 10e2 in lucas; freq a; smpl 29,65; y1 = log(n/pop); y2 = log(ql*n/rgnp); y3 = log(hw); y4 = log(hw/ql); x2 = log(rgnp/pop); x3 = log(ql); smpl 30,65; x1 = log(pgnp/pgnp(-1)); x4 = log(rgnp/rgnp(-1)); y5 = log(hw/hw(-1)); title 'Exercise 2, part (a) - direct 2SLS'; list ivs c x1-x4 y1(-1) y2(-1) y3(-1); 2sls(inst=ivs) y1 c y3 y3(-1) x1 y1(-1); ? (10.36) copy @dw dw2sls; 2sls(inst=ivs) y2 c y4 y2(-1) x4; ? (10.37) 2sls(inst=ivs) U c x1 y5 U(-1); ? (10.38) title 'Exercise 2, part (b) - 2sls by hand for (10.36)'; olsq(silent) y3 ivs; y3fit = @fit; ? first stage - reduced form olsq y1 c y3fit y3(-1) x1 y1(-1); ? second stage - without SE adjustment title 'Extension -- one more step to adjust the SEs'; forcst(static) y1fit c y3 y3(-1) x1 y1(-1); ? multiply coefs by ? structural RHS variables res = y1-y1fit; ? structural residuals mat ssr = res'res; set adj = ssr/@ssr; mat vcov = adj*@vcov; tstats(names=@rnms) @coef vcov; ? print a new table with correct SEs supres logl coef; olsq(silent) res c; ? compute Durbin-Watson from structural res supres; print @dw,dw2sls; ? compare with DW from direct 2SLS title 'Exercise 2, part (c) - 2sls by hand for (10.37),(10.38)'; y4fit = y3fit - x3; olsq y2 c y4fit y2(-1) x4; y5fit = y3fit - y3(-1); olsq U c x1 y5fit U(-1);