* * Enders, Applied Econometric Time Series, 4th edition * Example from Section 7.10, pp 458-461 * TAR model * open data terror_types.xls calendar(q) 1968:1 data(format=xls,org=columns) 1968:01 2000:04 date sky hostage assns threats bombings bomb_k bomb_w other \$ deaths casualities * linreg casualities # constant casualities{1 2 3} disp "Largest root for full model" 1.0/%polysmallestroot(%eqnlagpoly(0,casualities)) * @regcorrs(dfc=3,number=12,report,title="Residuals from AR(3)") %resids * @regRESET(h=3) * @tar(p=3,nreps=1000) casualities * linreg(smpl=casualities{%%delay}<=%%breakvalue) casualities # constant casualities{1 2 3} set res = %resids disp "Largest root for below threshold" 1.0/%polysmallestroot(%eqnlagpoly(0,casualities)) frml(lastreg) lowf * linreg(smpl=casualities{%%delay}>%%breakvalue) casualities # constant casualities{1 2 3} disp "Largest root for above threshold" 1.0/%polysmallestroot(%eqnlagpoly(0,casualities)) set res = %if(%valid(res),res,%resids) frml(lastreg) highf * @regcorrs(dfc=3,number=12,report,title="Residuals from Threshold AR") res * frml threshf casualities = %if(casualities{%%delay}<%%breakvalue,lowf,highf) group threshmodel threshf * spgraph(vfields=2,footer="Figure 7.13 Nonlinear Forecasts of Casualty Incidents") * * This gets into <> to <> the range of residuals available * for bootstrapping. * inquire(series=res) bstart bend * compute nsteps=25 compute ndraws=1000 * * <> is the first period of forecast, which will be the period * after the conditioning observations (1985:4). * compute fstart=1986:1 compute fend =fstart+nsteps-1 * set forecast fstart fend = 0.0 * do draws=1,ndraws boot entries fstart fend bstart bend set shocks fstart fend = res(entries) forecast(paths,model=threshmodel,from=fstart,to=fend,results=sims) # shocks set forecast fstart fend = forecast+sims(1) end do draws set forecast fstart fend = forecast/ndraws graph(header="Panel(a) Casualty Forecasts from 1985Q4",vlabels="Incidents") 2 # forecast fstart fend # casualities fstart-1 fend * * Same thing with different initial conditions * compute fstart=1999:1 compute fend =fstart+nsteps-1 * set forecast fstart fend = 0.0 * do draws=1,ndraws boot entries fstart fend bstart bend set shocks fstart fend = res(entries) forecast(paths,model=threshmodel,from=fstart,to=fend,results=sims) # shocks set forecast fstart fend = forecast+sims(1) end do draws set forecast fstart fend = forecast/ndraws graph(header="Panel(b) Casualty Forecasts from 1998Q4",vlabels="Incidents") 2 # forecast fstart fend # casualities fstart-1 fend * spgraph(done)