# The data used is contained in Splus #help(policy.dat) #Let's look at a few basic plots pol.mat = as.matrix(seriesData(policy.dat)) polsub.mat<-cbind(pol.mat[,3],pol.mat[,6]) tsplot(polsub.mat) title("TS Plot of Federal Fund Rate and Civilian Unemployment Rate") acf(polsub.mat) #Now let's model the series with an VAR of order 6 pol.mod = VAR(cbind(FFR,U)~ar(6),data=policy.dat) summary.VAR(pol.mod) plot.VAR(pol.mod,ask=F) # I would like to see the cross-correlation structure as well. pol.res<-as.matrix(residuals.VAR(pol.mod)) acf(pol.res) tsplot(pol.res) title("TS plot of Residuals from fitted VAR") # Let's see the confidence bands pol.forecast<-predict(pol.mod,12) plot.forecast(pol.forecast, policy.dat[,c("FFR","U")],n.old=20, hgrid=T, vgrid=T) title("12 Step Ahead Forecast - Confidence Bands at 1 Std. Error") plot(pol.forecast, policy.dat[,c("FFR","U")],n.old=50, hgrid=T, vgrid=T) title("12 Step Ahead Forecast - Confidence Bands at 1 Std. Error") # simulation forecasts from the fitted VAR sim.pred = simulate(pol.mod, n=10, n.rep=1000) apply(sim.pred, 2, rowMeans)