* * HANSEN.RPF * RATS Version 8, User's Guide, Example 3.6. * Hansen J Specification Test * cal(a) 1920 allocate 1941:1 open data klein.prn data(org=columns,format=prn) / cons $ profit privwage invst klagged1 prod govtwage govtexp taxes set wagebill = privwage+govtwage set trend = t-1931:1 set capital = klagged1+invst smpl 1921:1 1941:1 instruments constant trend govtwage govtexp taxes $ profit{1} capital{1} prod{1} * * Simple 2SLS. The test statistic will be included in the output. * linreg(inst) cons / resids # constant profit{0 1} wagebill * * Doing the test by regressing residuals on the full instrument set. * linreg resids # constant trend govtwage govtexp taxes $ profit{1} capital{1} prod{1} cdf chisqr %trsq 4 * * The two test statistics are slightly different because the J-statistic * produced by the first LINREG uses a degrees of freedom corrected * estimate of the residual variance. To get the identical result, you * need to multiply %trsq by (%nobs-4.0)/%nobs * * Test with the weight matrix adjusted for serial correlation and * heteroscedasticity. The test statistic here can't easily be computed * except by using some set of options for LINREG * linreg(inst,optimal,lags=1,lwindow=newey) cons # constant profit{0 1} wagebill * * This will produce the identical results to the included J-test * cdf chisq %uzwzu 4