* * BOOTVAR.RPF * RATS Version 8 * Bootstrapping example for VAR * compute lags=4 ;*Number of lags compute nvar=2 ;*Number of variables compute nstep=16 ;*Number of response steps compute ndraws=2500 ;*Number of draws * open data haversample.rat calendar(q) 1959 data(format=rats) 1959:1 2006:4 fm1 gdph * log gdph log fm1 ****************************************************************** * * Set up the system * dec vect[series] udraws(nvar) resids(nvar) resample(nvar) dec vect[equation] eqsample(nvar) eqbase(nvar) * system(model=varmodel) variables gdph fm1 lags 1 to lags det constant end(system) * estimate(resids=resids) compute rstart=%regstart(),rend=%regend() * * Set up the parallel system for the resampled data * system(model=bootvar) variables resample lags 1 to lags det constant end(system) * do i=1,nvar set resample(i) = %modeldepvars(varmodel)(i){0} end do i * declare vect[rect] %%responses(ndraws) declare rect[series] impulses(nvar,nvar) * infobox(action=define,progress,lower=1,upper=ndraws) "Bootstrap Simulations" do draw=1,ndraws * * Draw a bootstrapped sample * boot entries rstart rend do i=1,nvar set udraws(i) = resids(i)(entries(t)) end do i forecast(paths,model=varmodel,from=rstart,to=rend,results=resample) # udraws * * Estimate the model with resampled data * estimate(noprint,noftests,cvout=v) impulse(noprint,model=bootvar,cv=v,results=impulses,steps=nstep) * * Store the impulse responses * dim %%responses(draw)(nvar*nvar,nstep) ewise %%responses(draw)(i,j)=ix=%vec(%xt(impulses,j)),ix(i) infobox(current=draw) end do draw infobox(action=remove) * @MCGraphIRF(model=varmodel,page=all)