* * CHAPTER 16 * Page 641 * cal(q) 1957:1 all 2005:4 * open data ch14-16_macro2e.rat data(for=rats,compact=average) / lhur punew data(for=rats,compact=last) / fygm3 fygt1 * set p = log(punew) set infl = 400*log(punew/punew{1}) print(dates) 1960:1 2004:4 p infl set dinfl = infl-infl{1} smpl 1962:1 2004:4 * * * Equation (16.5) -- and 1-period ahead forecasts * linreg(robust) dinfl 1982:1 2004:4 di # constant dinfl{1 to 4} lhur{1 to 4} exclude # lhur {1 to 4} prj fd2005_inf 2005:1 2005:1 * * Equation (16.6) * linreg(robust) lhur 1982:1 2004:4 # constant dinfl{1 to 4} lhur{1 to 4} exclude # dinfl {1 to 4} display "Forecasts and actuals for 2005:1" prj fd2005_unemp 2005:1 2005:1 print(dates) 2005:1 2005:1 fd2005_inf fd2005_unemp dinfl lhur * * Iterated Multi-period forecasts * * AR(1) model -- equation (16.7) * linreg(robust, define=areq) dinfl 1962:1 2004:4 # constant dinfl{1} uforecast(equation=areq) twostep 2005:1 2005:2 disp "Forecast for 2004:4 to 2005:1 Change in Inflation Using 2004:4 Data" twostep(2005:1) disp "Forecast for 2005:1 to 2005:2 Change in Inflation Using 2004:4 Data" twostep(2005:2) * * AR(4) model -- equation (16.8) * linreg(robust,define=areq) dinfl 1962:1 2004:4 # constant dinfl{1 to 4} * uforecast(equation=areq) twostep 2005:1 2005:2 disp "Forecast for 2004:4 to 2005:1 Change in Inflation Using 2004:4 Data" twostep(2005:1) disp "Forecast for 2005:1 to 2005:2 Change in Inflation Using 2004:4 Data" twostep(2005:2) ** ** VAR Iterated Forecast ** * Iterated VAR forecast * Redo equations 16.5 and 16.6; define equations for forecasting purposes. * linreg(robust,define=dinfleq) dinfl 1982:1 2004:4 # constant dinfl{1 to 4} lhur{1 to 4} linreg(robust,define=lhureq) lhur 1982:1 2004:4 # constant dinfl{1 to 4} lhur{1 to 4} * * Forecasts with multiple equation systems are done using the FORECAST * instruction. FORECAST 2 2 2005:1 means two equations, two periods * starting 2005:1. The two equations to use are shown on the extra lines. * Note that the values are slightly different than those shown in the text * because these are done at full precision. * forecast(print) 2 2 2005:1 # dinfleq # lhureq print(dates) 2004:1 2004:4 dinfl lhur * * *** Direct Multistep Forecasts ** ** Newey-West standard errors ** Use rule of thumb for number of lags (.75*n**(1/3)) ** compute [integer] nlags = 1+fix(0.75*(%nobs**0.333)) ** ** Equation (16.13) ** ** linreg(robust,lags=nlags,lwindow=newey) dinfl 1982:1 2004:4 # constant dinfl{2 to 5} lhur{2 to 5} prj twostep 2005:2 2005:2 disp "Forecast for 2005:1 to 2005:2 Change in Inflation Using 2004:4 Data" twostep(2005:2) * ** DF-GLS test, done directly using regressions -- Results for Inflation ** compute n=2004:4-1961:4 compute astar=1.0-(7.0/float(n)) set z 1962:1 2004:4 = %if(t==1962:1,infl,infl-astar*infl{1}) set x 1962:1 2004:4 = %if(t==1962:1,1 ,1-astar) linreg z 1962:1 2004:4 # x set ya 1957:1 2004:4 = infl-%beta(1) linreg dinfl 1962:1 2004:4 # ya{1} dinfl{1 to 3} linreg dinfl 1962:1 2004:4 # ya{1} dinfl{1 to 2} linreg dinfl 1962:1 2004:4 # ya{1} dinfl{1 to 4} * * * Cointegration analyis (Note ... some of this analysis uses the same sample * periods as in SW1e. As an experiment, change the dates to use all available * data. Do the results change? Why? Results in Table 16.3 * smpl 1957:1 2005:4 set rs = fygt1-fygm3 set drs = rs-rs{1} set dfygm3 = fygm3-fygm3{1} set dfygt1 = fygt1-fygt1{1} print(dates) 1960:1 2004:4 fygm3 fygt1 rs compute n = (1999:4)-(1962:1)+1 compute astar=1.0-(7.0/float(n)) disp astar set x 1962:1 1962:1 = 1 set x 1962:2 1999:4 = 1-astar smpl 1962:1 1999:4 display " Lags AIC " compute [integer] maxlag = 0 linreg(noprint) dfygm3 # constant fygm3{1} compute c2 = %rss/float(%nobs) compute c3 = log(c2) compute c4 = float(%nreg)*2.0/float(%nobs) compute aic = c3+c4 display @5 #### maxlag @+3 ##.### aIC do maxlag=1,6 linreg(noprint) dfygm3 / # constant fygm3{1} dfygm3{1 to maxlag} compute c2 = %rss/float(%nobs) compute c3 = log(c2) compute c4 = float(%nreg)*2.0/float(%nobs) compute aic = c3+c4 display @5 #### maxlag @+3 ##.### aIC end do linreg(print) dfygm3 # constant fygm3{1} dfygm3{1 to 6} set z 1962:1 1962:1 = fygm3 set z 1962:2 1999:4 = fygm3-astar*fygm3{1} linreg z # x set ya 1959:1 1999:4 = fygm3-%beta(1) linreg(print) dfygm3 # ya{1} dfygm3{1 to 6} display " Lags AIC " compute [integer] maxlag = 0 linreg(noprint) dfygt1 # constant fygt1{1} compute c2 = %rss/float(%nobs) compute c3 = log(c2) compute c4 = float(%nreg)*2.0/float(%nobs) compute aic = c3+c4 display @5 #### maxlag @+3 ##.### aIC do maxlag=1,6 linreg(noprint) dfygt1 # constant fygt1{1} dfygt1{1 to maxlag} compute c2 = %rss/float(%nobs) compute c3 = log(c2) compute c4 = float(%nreg)*2.0/float(%nobs) compute aic = c3+c4 display @5 #### maxlag @+3 ##.### aIC end do linreg(print) dfygt1 # constant fygt1{1} dfygt1{1 to 3} set z 1962:1 1962:1 = fygt1 set z 1962:2 1999:4 = fygt1-astar*fygt1{1} linreg z # x set ya 1959:1 1999:4 = fygt1-%beta(1) linreg(print) dfygt1 # ya{1} dfygt1{1 to 3} display " Lags AIC " compute [integer] maxlag = 0 linreg(noprint,robust) drs # constant rs{1} compute c2 = %rss/float(%nobs) compute c3 = log(c2) compute c4 = float(%nreg)*2.0/float(%nobs) compute aic = c3+c4 display @5 #### maxlag @+3 ##.### aIC do maxlag=1,6 linreg(noprint,robust) drs # constant rs{1} drs{1 to maxlag} compute c2 = %rss/float(%nobs) compute c3 = log(c2) compute c4 = float(%nreg)*2.0/float(%nobs) compute aic = c3+c4 display @5 #### maxlag @+3 ##.### aIC end do linreg(print) drs # constant rs{1} set z 1962:1 1962:1 = rs set z 1962:2 1999:4 = rs-astar*rs{1} linreg z # x set ya 1959:1 1999:4 = rs-%beta(1) linreg(print) drs # ya{1} * * Equation 16.26 * linreg fygt1 # constant fygm3 set rsh 1959:1 1999:4 = fygt1-%beta(1)-%beta(2)*fygm3 set drsh 1959:1 1999:4 = rsh-rsh{1} display " Lags AIC " compute [integer] maxlag = 0 linreg(noprint,robust) drsh # rsh{1} compute c2 = %rss/float(%nobs) compute c3 = log(c2) compute c4 = float(%nreg)*2.0/float(%nobs) compute aic = c3+c4 display @5 #### maxlag @+3 ##.### aIC do maxlag=1,6 linreg(noprint,robust) drsh / # rsh{1} drsh{1 to maxlag} compute c2 = %rss/float(%nobs) compute c3 = log(c2) compute c4 = float(%nreg)*2.0/float(%nobs) compute aic = c3+c4 display @5 #### maxlag @+3 ##.### aIC end do linreg(print) drsh # rsh{1} * * * VECM Model equations (16.27) and (16.28) * linreg(print,robust) dfygm3 # constant dfygm3{1 to 2} dfygt1{1 to 2} rs{1} linreg(print,robust) dfygt1 # constant dfygm3{1 to 2} dfygt1{1 to 2} rs{1} * end(reset) * * GARCH Model for NYSE Returns * open data ch16_nyse.asc data(for=free,org=obs) 1 4003 dt nyse set ret = 100*log(nyse/nyse{1}) garch(p=1,q=1,method=bhhh,hseries=h,resids=u) 2 4003 ret set upper = sqrt(h) set lower = -sqrt(h) graph(header="Figure 16.3 GARCH(1,1) Model NYSE Returns") 3 # u # upper / 2 # lower / 2