* * Example 5.3 from page 83 * Hausman test (OLS vs IV) * * This example is written to match the results given in the text - it uses * realgdp rather than realdpi as the income variable throughout. * open data tablef5-1[1].txt calendar(q) 1950 data(format=prn,org=columns) 1950:1 2000:4 year qtr realgdp realcons realinvs realgovt realdpi $ cpi_u m1 tbilrate unemp pop infl realint * * Hausman test. Run the regression by OLS and by IV. Save the (x'x)**-1, beta and * seesq from OLS. To match up with the test statistic, we use the estimate for the * residual variance that doesn't include a degrees of freedom adjustment. * linreg realcons 1950:2 * # constant realgdp compute xxols=%xx,betaols=%beta,seesqols=%sigmasq instruments constant realgdp{1} realcons{1} linreg(inst) realcons 1950:2 * # constant realgdp * * Test the IV coefficient vector against OLS. The FORM=CHISQUARED is used because the * variances have already been included in the covariance matrix. * compute cvdiff=seesqols*(%xx-xxols) test(title="Hausman Test",all,form=chisquared,vector=betaols,covmat=cvdiff) * * Wu test * linreg realgdp # constant realgdp{1} realcons{1} prj yfit linreg realcons # constant realgdp yfit exclude(title="Wu test") # yfit * * These tests can also be done using the @RegWuTest procedure. Set the instrument * list (although it hasn't changed, we'll put it here again), run the regression * using LINREG and then run the RegWuTest procedure. You'll notice that the * F-test form matches the output from the Wu test and the chi-squared form * matches the output from the Hausman test. * instruments constant realgdp{1} realcons{1} linreg realcons 1950:2 * # constant realgdp @RegWuTest