
An R package for Bayesian Forecasting with Large Vector Autoregressions
Provides fast and efficient procedures for Bayesian estimation and forecasting using state-of-the-art Vector Autoregressions. This package includes the model proposed by Chan (2020), that is, a Bayesian Vector Autoregression with Minnesota priors and a flexible structure of the error term specification. The latter includes: conditional multivariate normal or Student’s t distributions, as well as homoskedastic or heteroskedastic specifications with a common volatility modelled by centred or non-centred Stochastic Volatility. Additionally, the package facilitates predictive analyses using density forecasting and forecast-error variance decompositions. All this is complemented by simple workflows, useful plots and summary functions, and comprehensive documentation. The ‘bvars’ package aligns with R packages ‘bsvars’ by Woźniak (2024), ‘bsvarSIGNs’ by Wang & Woźniak (2025), and ‘bpvars’ by Woźniak (2025) regarding objects, workflows, and code structure, and they constitute an integrated toolset.
Y = A X + E (VAR equation)
E | X ~ MN(0, O, S) (error term normality)
Y,X,E,A,S, andO allowing for heteroskedasticity and
non-normality of the error term.S and
column-specific diagonal covariance matrix O of order
T.A and S follow a
matrix-variate normal inverse Wishart prior featuring characteristics of
the Minnesota priors.O facilitates the following
customisation of the error term specification:
specify_bvar$new()
functionestimate() methodforecast() methodcompute_variance_decompositions()plot() and summary() methods to gain
the insights into the core of the empirical problem.**************************************************|
bvars: Forecasting with Large |
Bayesian Vector Autoregressions |
**************************************************|
Gibbs sampler for the BVAR model |
**************************************************|
Progress of the MCMC simulation for 1000 draws
Every draw is saved via MCMC thinning
Press Esc to interrupt the computations
**************************************************|
0% 10 20 30 40 50 60 70 80 90 100%
[----|----|----|----|----|----|----|----|----|----|
*************************************
The beginnings are as easy as ABC:
library(bvars) # load the package
spec = specify_bvar$new( # specify the model
us_macro_chan, # data
p = 4, # number of lags
common_volatility = "ncSV", # heteroskedasticity
distribution = "t", # Student t error term
stationary = rep(TRUE, ncol(us_macro_chan)) # Minnesota prior spec
)
burn = estimate(spec, S = 10000) # run the burn-in
post = estimate(burn, S = 10000) # estimate the model
summary(fore) # estimation summary
fore = forecast( # forecast the model
post, # estimation output
horizon = 6 # forecast horizon
)
plot(fore) # plot the forecasts
summary(fore) # forecast summary forecasts
fevd = compute_variance_decompositions(
post, horizon = 6) # compute variance decompositions
plot(fevd) # plot variance decompositionsThe bvars package supports a simplified workflow
using the |> pipe:
us_macro_chan |> # data
specify_bvar$new(p = 4) |> # specify the model
estimate(S = 10000) |> # run the burn-in
estimate(S = 10000) -> post # estimate the model
post |> forecast(horizon = 6) |> plot() # forecasting
post |> compute_variance_decompositions(horizon = 6) |> plot()Now, you’re ready to analyse your model and forecasts!
This beautiful logo can be reproduced in R using this file.
You must have a cpp compiler. Follow the instructions from Section 1.3. by Eddelbuettel & François (2023). In short, for Windows: install RTools, for macOS: install Xcode Command Line Tools, and for Linux: install the standard development packages.
The newest version of the package can be installed by typing:
install.packages("bvars")
The developer’s version of the package with the newest features can be installed by typing:
devtools::install_github("bsvars/bvars")
The package is under intensive development. Your help is most welcome! Please, have a look at our issues to learn what we’re working on. Thank you!
Rui holds a Master’s degree in Mathematics from the University of Melbourne, where her research focused on copula models, and a Master’s degree in Statistics from Columbia University. She earned her Bachelor’s degree in Mathematics and Economics from the London School of Economics and Political Science. She is currently on a temporary break from academia and is working in investment banking at Morgan Stanley.
Andrés is a Bayesian econometrician whose research focuses on causal inference and structural, hierarchical, and mixture models. He develops econometric methodology and computational tools in R for applied econometric analysis.
Tomasz is a Bayesian econometrician and a Senior Lecturer at the University of Melbourne. He develops methodology for empirical macroeconomic analyses and programs in R and C++ using Rcpp.