* * Example 8.4 from pp 356-367 * open data m-ibmspln.dat calendar(m) 1926 data(format=free,org=columns) 1926:1 1999:12 ibm sp500 * * Using AIC to examine models (without skipped lags) * @varlagselect(lags=6,crit=aic) # ibm sp500 * * Estimation of the VAR with just lags 1 and 3 * system(model=full) variables ibm sp500 lags 1 3 det constant end(system) * estimate(sigma) * * The simplified model is specified a bit differently because it doesn't treat * the variables symmetrically. The lags of SP500 are put in as "deterministic" * variables * system(model=simplified) variables ibm sp500 det constant sp500{1 3} end(system) * estimate(sigma,resids=simpresids) * * Multivariate Q test for the residuals from the simplified model. Correct for * four degrees of freedom * @mvqstat(lags=4,dfc=4) # simpresids @mvqstat(lags=8,dfc=4) # simpresids * * Compute forecasts and standard errors. The forecasts will be in series * forecast(1) (ibm, since it's the first equation in the system) and forecast(2) * and the standard errors in stderrs(1) and stderrs(2). * forecast(model=simplified,steps=6,results=forecast,stderrs=stderrs) print(picture="*.##") 2000:1 2000:6 forecast(1) stderrs(1) forecast(2) stderrs(2) * * Analysis using BIC rather than AIC (pp 362-365) * @varlagselect(lags=6,crit=bic) # ibm sp500 * system(model=full) variables ibm sp500 lags 1 det constant end(system) estimate(resids=resids) * spgraph(hfields=2,footer="Figure 8.5 Residual plots of fitting a VAR(1) to monthly log returns") graph(header="IBM") # resids(1) graph(header="SP500") # resids(2) spgraph(done) * forecast(model=full,steps=6,results=forecast,stderrs=stderrs) spgraph(hfields=2,footer="Figure 8.6. Forecasting plots from a VAR(1) model") set lower 2000:1 2000:6 = forecast(1)-stderrs(1) set upper 2000:1 2000:6 = forecast(1)+stderrs(1) graph(header="IBM") 4 # ibm 1999:1 1999:12 # forecast(1) 2000:1 2000:6 # lower 2000:1 2000:6 3 # upper 2000:1 2000:6 3 set lower 2000:1 2000:6 = forecast(2)-stderrs(1) set upper 2000:1 2000:6 = forecast(2)+stderrs(1) graph(header="SP500") 4 # sp500 1999:1 1999:12 # forecast(2) 2000:1 2000:6 # lower 2000:1 2000:6 3 # upper 2000:1 2000:6 3 spgraph(done) * * This does impulse responses with error bands using Monte Carlo integration. * You'll note an apparent difference with the response of IBM to SP500 compared * with that in the book. However, that is due to a difference in the scale of the * graph. Graphing responses of IBM to the two shocks with different scales * exaggerates the effect of the SP500 shock. * @montevar(model=full,steps=6)