* * Example from page 270 * open data auto2.asc calendar(q) 1959:1 data(format=prn,org=columns) 1959:1 1992:1 y x2 x3 x4 * * Run the first step regression, retaining the residuals * linreg y / resids # x2 x3 x4 constant * @regactfit(footer="Figure 8.3 Regression output from Table 8.6") * * This does the Engle-Granger test on the residuals. Because the critical values * change with the number of endogenous variables, you have to provide that * information as an option. * @egtestresids(nvar=4) resids * * The alternative procedure is EGTEST which also does the first step regression. * @egtest # y x2 x3 x4 * * Create the dummy for 1974:1 * set dummy74 = (t==1974:1) * linreg y / resids # x2 x3 x4 constant dummy74 @regactfit(footer="Figure 8.4 Cointegrating Relation with a Dummy Variable") * * These will only give approximate critical values, because the distribution * would change with the addition of the dummy. * @egtestresids(nvar=4) resids * * This estimates the dynamic regression on y. The SUMMARIZE instructions analyze * the sum of the listed coefficients * linreg y / resids # x2{0 to 5} x3{0 to 5} x4{0 to 5} y{1 to 5} dummy74 constant summarize # y{1 to 5} summarize # x2{0 to 5} summarize # x3{0 to 5} summarize # x4{0 to 5} * @regactfit(footer="Figure 8.5 Regression Output from Table 8.7") * * Do the specification tests * stats resids * * AR(4) test * linreg resids # %reglist() resids{1 to 4} cdf(title="Test for Residual Autocorrelation") chisqr %trsquared 4 * * Test for ARCH * set ressqr = resids**2 linreg ressqr # constant ressqr{1} * * Model reparameterized in differences. * set dy = y-y{1} set dx2 = x2-x2{1} set dx3 = x3-x3{1} set dx4 = x4-x4{1} linreg y # x2{1} dx2{0 to 4} x3{1} dx3{0 to 4} x4{1} dx4{0 to 4} y{1} dy{1 to 4} dummy74 constant * * Check various exclusions and prune the model * exclude # dx2{4} dx3{4} dx4{4} dy{4} linreg y # x2{1} dx2{0 to 3} x3{1} dx3{0 to 3} x4{1} dx4{0 to 3} y{1} dy{1 to 3} dummy74 constant exclude # dx2{1 2} dx3{1 to 3} dx4{1 to 3} linreg y # x2{1} dx2{0 3} x3{1} dx3{0} x4{1} dx4{0} y{1} dy{1 to 3} dummy74 constant exclude # dx3 linreg y # x2{1} dx2{0 3} x3{1} x4{1} dx4{0} y{1} dy{1 to 3} dummy74 constant * * Stepwise regression * stwise(method=backwards) y # x2{1} dx2{0 to 4} x3{1} dx3{0 to 4} x4{1} dx4{0 to 4} y{1} dy{1 to 4} dummy74 constant