Variable Selection for VARs

This code replicates the results in the paper

Korobilis, D. (2013). VAR Forecasting Using Bayesian Variable Selection, Journal of Applied Econometrics, 28, pp. 204-230.

There are several models estimated here with VARIABLE SELECTION (see the article for details):

1) DIRECT_KM_VAR: VAR (DIRECT forecasts)

2) DIRECT_KM_TVP_VAR: Time varying parameters VAR (DIRECT forecasts)

3) FORE_KM_VAR: VAR (ITERATED forecasts, RIDGE prior)

4) FORE_KM_VAR_LASSO: VAR (ITERATED forecasts, SHRINKAGE prior)

5) FORE_KM_VAR_MIN: VAR (ITERATED forecasts, MINNESOTA prior)

6) FORE_KM_VAR_LARGE: VAR (ITERATED forecasts, RIDGE prior, LARGE dimension-13 variables)

7) FORE_KM_VAR_SB: Structural Breaks VAR (ITERATED forecasts, RIDGE prior)

8) FORE_KM_TVP_VAR: Time varying parameters VAR (ITERATED forecasts, MINNESOTA prior, CARTER&KOHN filter)

9) FORE_KM_TVP_VAR_DK: Time varying parameters VAR (ITERATED forecasts, MINNESOTA prior, DURBIN&KOOPMAN filter)

For non-forecasting versions of these models (i.e. scripts which only do estimation) see the folder ORIGINAL FILES.

If you are not that experienced and you want to get a first idea about how variable selection works, download the VAR_Selection_DEMO.zip code (you can find it at the bottom of this page) which is simpler and shows the efficiency of the variable selection algorithm on an artificially generated dataset.

NOTE: If you try to use this code with your own data then you might experience overflow/underflow issues. This is because the variable selection algorithm needs to evaluate multiple times conditional likelihood functions (i.e. when γ=0 and when γ=1), and these functions are exponential. In this case you will need to evaluate instead the log-likelihoods (which remove (-/+ Inf) problems caused by taking exp of a large positive or negative number), and calculate posterior model probabilities by transforming back to the original scale using the exponential function. Additionally, assume CL1 is the conditional likelihood under γ=0 (VAR coefficient is restricted) and CL2 is the likelihood under γ=1 (VAR coefficient is unrestricted), then we can use the property that:

log(CL1 + CL2) = log(CL1) + log( 1 + CL2/CL1) ) = log(CL1) + log( 1 + exp(log(CL2) - log(CL1)))

This code is for experienced users only who can feel comfortable enough to use it and alter it.


Download code here: VAR_VARIABLE_SELECTION.zip and VAR_Selection_DEMO.zip