VARBOOTSETUP Procedures |
This pair of procedures (on the file VARBOOTSETUP.SRC, since you have to use it first) is used to generate bootstrapped data for a Vector Autoregression using a conventional parametric bootstrap. However, their use isn't limited only to VAR's—you can use them to generate data from almost any linear model.
@VARBootSetup(MODEL=inputmodel) outputmodel
@VARBootDraw(RESIDS=VECT[SERIES] of residuals,MODEL=inputmodel) start end lower upper
Parameters for @VARBootSetup
|
outputmodel |
(optional) parallel VAR model defined using the bootstrapped series. Note that this will always be a basic VAR, even if inputmodel isn't. |
Options for @VARBootSetup
MODEL=inputmodel
This is the linear model (typically a VAR) which is to be used as the source for the bootstrapped data. This should already have been estimated, and you need to have saved the residuals from the estimation in a VECT[SERIES] (typically, with the RESIDS option on the estimation instruction).
Parameters for @VARBootDraw
|
start, end |
range of entries to generate in the bootstrapped series. By default, this is the standard workspace which is almost certainly wrong, so make sure you use these. |
|
lower, upper |
lower and upper bounds (inclusive on both ends) of the source entries. These default to start and end but could be different if you are bootstrapping out-of-sample. (In that case, lower and upper would be the sample range of the estimates). |
Options for @VARBootDraw
Neither of these is actually "optional". They are required to provide the necessary information for generating the data.
MODEL=inputmodel
This is the MODEL that is used in generating the bootstrapped data, so it should have the coefficients that you want to use for the parametric bootstrap. Although it will usually be the same as model using in @VARBootSetup, it could be different, such as same structure, different coefficients.
RESIDS=VECT[SERIES] of residuals
This is a VECT[SERIES] with the residuals to be used in generating the bootstrapped data. This is typically created using the RESIDS option on the estimation instruction (ESTIMATE or SUR).
Description
@VARBootSetup doesn't really do much. It sets up a VECT[SERIES] called %%VARResample which will hold the bootstrapped data. This has the same number of variables as the inputmodel has equations, and they correspond to the dependent variables of inputmodel in order. They are initialized to the original data from the inputmodel so any pre-sample values will carry over. If you provide a name for outputmodel, it will also set up in it a parallel VAR in terms of the %%VARResample series. This is a basic VAR with CONSTANT as the only deterministic. If you need something other than that, you'll have to define the parallel model yourself.
@VARBootDraw generates a new set of information in the %%VARResample series. This is done by drawing a set of random entry numbers and simulating the inputmodel over the start to end range using resampled information from the VECT[SERIES] of residuals. Note that it does not estimate the model on the bootstrapped data—that's up to you.
Variables Defined
|
%%VARResample |
VECT[SERIES] of resampled data |
Example
This gets bootstrapped estimates of the confidence bands for a three variable VAR doing unit shocks to all variables (FACTOR=%IDENTITY(NVAR) on the IMPULSE instruction). Note that the @VARBootSetup is outside the draw loop and the @VARBootDraw is inside. Note also the use of %REGSTART() and %REGEND() to get the range for bootstrapping from the range of the ESTIMATE instruction.
*
* Lutkepohl, New Introduction, example from 3.7.4, pp 126-130
* VAR; Impulse responses; Confidence bands by bootstrapping
*
open data e1.dat
calendar(q) 1960
data(format=prn,org=columns,skips=6) 1960:01 1982:04 invest income cons
*
set dinc = log(income/income{1})
set dcons = log(cons/cons{1})
set dinv = log(invest/invest{1})
*
system(model=varmodel)
variables dinv dinc dcons
lags 1 2
det constant
end(system)
estimate(sigma,resids=resids) * 1978:4
*
@VARBootSetup(model=varmodel) bootvar
*
compute rstart=%regstart()
compute rend =%regend()
*
compute bootdraws=2000
compute nvar =%nvar
compute nsteps=8
declare vect[rect] %%responses
dim %%responses(bootdraws)
declare rect[series] impulses(nvar,nvar)
declare vect ix
*
infobox(action=define,progress,lower=1,upper=bootdraws) "Bootstrap Simulations"
do draw=1,bootdraws
@VARBootDraw(model=varmodel,resids=resids) rstart rend
*
* Estimate the model with resampled data
*
estimate(noprint,noftests)
impulse(noprint,model=bootvar,factor=%identity(nvar),results=impulses,steps=nsteps)
*
* Store the impulse responses
*
dim %%responses(draw)(nvar*nvar,nsteps)
ewise %%responses(draw)(i,j)=ix=%vec(%xt(impulses,j)),ix(i)
infobox(current=draw)
end do draw
infobox(action=remove)
*
@mcgraphirf(model=varmodel,$
center=median,percent=||.025,.975||,$
footer="Figure 3.10 95% bootstrap bands")
Copyright © 2025 Thomas A. Doan