* * GIV.RPF * Example of generalized instrumental variables (GMM) * User's Guide, example from Section 4.9. * * This example runs through the calculations for the single return * models in Hansen and Singleton (1982) on a constructed data set. * calendar(q) 1960:1 open data hsdata.wks * data(format=wks,org=cols) 1960:1 1987:4 c price div * set consgrow = c/c{1} set realret = (price+div)/price{1} * nonlin discount riskaver frml h = discount*realret(t)*consgrow(t)^riskaver-1 compute discount = .99,riskaver = -.95 * * Estimate the model with six lags in the information set * instruments constant consgrow{1 to 6} realret{1 to 6} nlls(inst,frml=h,optimal) * * * Do specification tests on lag lengths 1, 2, 4 and 6. These are done * over a common interval (the range supported by the six lag estimation * - %regstart() returns the start entry from the last regression). The * NLLS output is suppressed and the tests results are displayed using * cdf. * compute start=%regstart() dofor nlag = 1 2 4 6 instruments constant consgrow{1 to nlag} realret{1 to nlag} nlls(inst,noprint,frml=h,optimal) * start * cdf(title="Specification Test for "+nlag+" lags") \$ chisqr %jstat 2*nlag-1 end dofor * * Same specification tests using REPORT to pretty up the output * report(action=define,hlabel=||"Lags","J-Stat","P-Value"||) dofor nlag = 1 2 4 6 instruments constant consgrow{1 to nlag} realret{1 to nlag} nlls(inst,noprint,frml=h,optimal) * start * report(atcol=1,row=new) nlag %jstat %jsignif end dofor report(action=format,atcol=2,width=8) report(action=format,atcol=3,picture="#.###") report(action=show)