Search code examples
rvariablesvarstatistics-bootstrap

Estimation residuals from VAR estimation (vars package)


I'm currently estimating a VAR model followed by the estimation of generalized impulse response functions. To obtain SE of those, I'm supposed to do some bootstrapping first.

This procedure starts with "estimating the parameters of the VAR model and extracting the estimation residuals, denoted Ût."

Now, I'm estimating my var model with the vars package as follows

varendoA<-data.frame(value_ts,value2_ts, price_ts, price2_ts)
library(vars)
fitvar<- VAR(varendo, type = c("both"), season = christmas, lag.max = 12,ic = c("AIC"))
summary(fitvar)

The model contains 5 variables with 104 observations, a trend, constant and a dummy for the Christmas period and outputs a result with 5 lags.

Now when I want to extract its residuals residuals(fitvar) I get a list of 99 numbers per variable.

I'm supposed to use these residuals to generate bootstrap residuals (randomly drawing with replacement from the obtained ones) and use these with the estimated equations to generate new, bootstrapped time series to re-estimate the VAR and IRFs (and in the end obtain SEs for my estimations).

Since I'm supposed to recursively compute the new time series as follows:

enter image description here

shouldn't I get a list of 104 residuals per variable instead of 99? I'm a bit confused with this whole generating process.

Any help is more than appreciated.


Solution

  • In an autoregressive (AR) model, variables are forecast using linear combinations of past values of the variable. Since you have set lag.max = 12, you are allowing VAR to select a model that uses, at most, 12 lagged values as predictors.

    Since your model uses 5 lags, VAR cannot fit values to the first 5 observations of your variables. This is because those first 5 observations are being used to fit a value to the 6th observation. Therefore, the number of residuals will be the number of observations minus the AR model order.