* * Examples from section 12.9, pages 478-483 * Estimation with autocorrelated errors * cal 1959 open data table12-4.prn data(format=prn,org=columns) 1959:1 1998:1 * * OLS regression * linreg y # constant x compute rssols=%rss * * First difference regression * set dx = x-x{1} set dy = y-y{1} linreg dy # dx * * Berenblutt-Webb test. Note that there is a typo in the text, with an incorrect * value for the sum of squared residuals from the FD regression, and consequent * error in the G statistic. * disp "G-statistic" %rss/rssols * * GLS regressions * linreg y / resids # constant x compute rhodw=1.0-.5*%durbin linreg resids # resids{1} compute rhoar=%beta(1) disp "Rho from DW" rhodw "Rho from regression" rhoar * * Filter data using the rho from the DW. We transform the constant as well. This * has no effect on the slope coefficient or any of the summary statistics, but * gives a comparable value for the intercept to the original regression. * set fx = x-rhodw*x{1} set fy = y-rhodw*y{1} set fc = (1-rhodw) linreg fy # fc fx * * Same thing, but with the rho from the one lag regression on the residuals * set fx = x-rhoar*x{1} set fy = y-rhoar*y{1} set fc = (1-rhoar) linreg fy # fc fx * * Packaged methods. "HILU" (the default) is Hildreth Lu, which is a grid search * procedure. "CORC" is Cochrane-Orcutt as described in the book. Those should * give very similar results. "MAXL" is a maximum likelihood procedure which uses * all observations. It's similar to the Prais-Winsten estimator described in the * text, but also includes log(variance) terms. The value of rho for CORC doesn't * quite match up because the RATS instruction does a few more iterations. * * First, however, we use AR1 with an input value of rho. This replaces the last * filtered regression above. * ar1(rho=rhoar) y # constant x * ar1(method=hilu) y # constant x ar1(method=corc) y # constant x ar1(method=maxl) y # constant x * * OLS with Newey-West standard errors. This allows for autocorrelation of up to * four lags. * linreg(lwindow=newey,lags=4,robusterrors) y # constant x * ar1(method=corc,define=ar1eq) y * 1996:1 # constant x uforecast(equation=ar1eq) dynfore 1997:1 1998:1