BVARs:
the Great Grimpen Mire
Boris Demeshev
Oxana Malakhovskaya
2016-09-22
September Equinox
High predictive power
Underused and confused
BVAR = VAR + Bayesian approach
VAR: \[ \begin{cases} y_t =\Phi_{const}+ \Phi_1 y_{t-1} + \Phi_2 y_{t-2} +\ldots + \Phi_p y_{t-p} + \varepsilon_t \\ \varepsilon_t\sim \mathcal{N}(0,\Sigma) \end{cases} \]
Bayesian approach:
Impose some prior distribution on \(\Sigma\), \(\Phi_{const}\), \(\Phi_1\), \(\Phi_2\), …
Use formula for conditional probability \(p(\theta|data) \sim p(data|\theta) \cdot p(\theta)\) to obtain posterior distribution.
Use posterior distribution for forecasting.
Robert Litterman, 1979, Techniques of forecasting using vector autoregressions
Rao Kadiyala and Sune Karlsson, 1997, Numerical Methods for Estimation and Inference in Baesian VAR-Models
Christopher A. Sims and Tao Zha, 1998, Bayesian methods for dynamic multivariate models
Sune Karlsson, 2012, Forecasting with Bayesian Vector Autoregressions
more than 7 000 hits in scholar.google.com
Note: ARMA gives more than 700 000 hits!
Great Grimpen Mire of prior distributions
Great Grimpen Mire of software
No MCMC in bachelor probability course
Structural: \(Ay_t = B_0+ B_1 y_{t-1} +\ldots + B_p y_{t-p} + u_t\)
Reduced form: \(y_t =\Phi_{const}+ \Phi_1 y_{t-1} + \Phi_2 y_{t-2} +\ldots + \Phi_p y_{t-p} + \varepsilon_t\)
Link: \(B_i = A \Phi_i\).
The parameters \(\Phi_i\) may change over time.
\(y_t =\Phi_{const}+ \Phi_1 y_{t-1} + \Phi_2 y_{t-2} +\ldots + \Phi_p y_{t-p} + \varepsilon_t\)
We should impose prior on \(\Sigma\), \(\Phi_{const}\), \(\Phi_1\), \(\Phi_2\), …
Here \(y_t\) is multivariate: \(m\times 1\).
For \(m=10\) variables and \(p=4\) lags we have more than 400 parameters.
Confusing names for priors
No clear classification of priors
Contradictory notation
Results in:
Coding mistakes
You should struggle a lot to understand
Underuse of BVARs
\[ \begin{cases} y_t =\Phi_{const}+ \Phi_1 y_{t-1} + \Phi_2 y_{t-2} +\ldots + \Phi_p y_{t-p} + \varepsilon_t \\ \varepsilon_t\sim \mathcal{N}(0,\Sigma) \end{cases} \]
We should place prior on:
Covariance matrix \(\Sigma\)
Coefficients \(\Phi_i\)
Prior \(p(\Sigma)\) and prior \(p(\Phi_{const}, \Phi_1, \ldots, \Phi_p)\)
Prior \(p(\Sigma)\) and prior \(p(\Phi_{const}, \Phi_1, \ldots, \Phi_p | \Sigma)\)
\[ \begin{cases} \Sigma \sim \mathcal{IW}(\underline S,\underline \nu) \\ \phi \sim \mathcal{N}(\underline \phi, \underline \Xi) \\ p(\phi, \Sigma) = p(\phi)\cdot p(\Sigma) \end{cases} \]
\[ \begin{cases} \Sigma = const\\ \phi \sim \mathcal{N}(\underline \phi, \underline \Xi) \end{cases} \]
\[ \begin{cases} \Sigma \sim \mathcal{IW}(\underline S,\underline \nu) \\ \phi | \Sigma \sim \mathcal{N}(\underline \phi, \Sigma \otimes \underline \Omega) \end{cases} \]
\[ \begin{cases} \Sigma \sim \mathcal{IW}(\underline S,\underline \nu) \\ \phi | \Sigma \sim \mathcal{N}(\underline \phi, \Sigma \otimes \underline \Omega) \end{cases} \]
Explicit formula for posterior distribution
You can sample directly from posterior
Posterior distribution can be calculated in a second way:
Add artificial observations
Use OLS with augmented dataset
\[ \begin{cases} \Sigma \sim \mathcal{IW}(\underline S,\underline \nu) \\ \phi | \Sigma \sim \mathcal{N}(\underline \phi, \Sigma \otimes \underline \Omega) \end{cases} \]
a bunch of separated MATLAB
functions. Poor documentation, poor stability
Eviews
point and click interface. Poor documentation. Poor stability.
R
-packages:
BMR
. Good documentation. Poor stability.MSBVAR
. Poor documentation. Poor stability.bvarsv
. Good documentation. Complex model.Almost no integration at all.
Open source. Only R/python/Julia/gretl. MATLAB/Stata/Eviews are almost dead.
Well documented. Consistent notation with major articles.
Robust. Sever multicollinearity problem. Should not throw errors!
Easy to use. Reasonable defaults to plug and play!
Well integrated. Do not reinvent the weel.
Fast. Probably Julia/C++ implementation.
R
package bvarr
Open source. OK
Well documented. Almost OK. Article «BVAR mapping» should soon appear in Prikladnaya ekonometrika.
Easy to use. Almost OK. Some defaults are imposed. More testing is on the way.
Robust. Almost OK. We use SVD and other tricks of the trade.
We never use the formula \(\hat\beta = (X'X)^{-1}X'y\) :)
bvarr
todo list:More priors. Only conjugate-inverse normal Wishart for the moment
Visualise priors. Almost no one really understands priors.
Well integrated. Integration with forecast
, vars
and BMR
R
-packages is planned.
Fast. Irrelevant for conjugate-inverse normal Wishart.
library(ggplot2)
qplot(rnorm(100)) + xlab("Привет, Ира!")
install.packages(c("sophisthse", "devtools", "dplyr"))
devtools::install_github("bdemeshev/bvarr")
library("dplyr")
library("sophisthse")
library("bvarr")
y <- sophisthse(c("UNEMPL_Y", "GDPVA_T_Y_DIRI"))
y <- y[, c("UNEMPL_Y", "GDPVA_T_Y_DIRI")] %>% na.omit
setup <- bvar_conj_setup(y, p = 4)
model <- bvar_conj_estimate(setup)
y_hat <- bvar_conj_forecast(model, h = 2)
If you are a probability/econometrics lecturer. Just introduce MCMC in the course!
If you are a student. Ask your lecturer about Bayesian approach and MCMC. It’s modern, stylish and ye-ye!
Don’t panic!
Basic course. Use MCMC as a black box for the conditional probability formula.
Advanced course. Use MCMC to illustrate the convergence in distribution.
R
+ MCMCpack
.R
/python
/Julia
+ STAN
/JAGS
Julia
+ Lora
/Mamba
python
+ PyMC
An analog of M3-competition for multivariate time series?
A good multivariate time series plot? For 20+ series at once?
How to obtain \((X'X)^{-1}\) if SVD of \(X\) fails?
How to visualise Inverse-Wishart prior? Or prior for 400+ coefficients?
Any experience with MCMC in bachelor courses?
Boris Demeshev: boris.demeshev@gmail.com
Oxana Malakhovskaya: oxana.malakhovskaya@gmail.com
Project web-page: bdemeshev.github.io/bvarr
Я вам, ребята, на мозги не капаю, но вот он, перегиб и парадокс: кого-то выбирают римским папою, кого-то запирают в тесный бокс.
Владимир Высоцкий