Provides fast and efficient procedures for Bayesian analysis of Structural Vector Autoregressions. This package estimates a wide range of models, including homo-, heteroskedastic, and non-normal specifications. Structural models can be identified by adjustable exclusion restrictions, time-varying volatility, or non-normality, and include exclusion restrictions on autoregressive parameters. They all include a flexible three-level equation-specific local-global hierarchical prior distribution for the estimated level of shrinkage for autoregressive and structural parameters. Additionally, the package facilitates predictive and structural analyses such as impulse responses, forecast error variance and historical decompositions, forecasting, verification of heteroskedasticity, non-normality, and hypotheses on autoregressive parameters, as well as analyses of structural shocks, volatilities, and fitted values. Beautiful plots, informative summary functions, and extensive documentation including the vignette by Woźniak (2025)
An R package for Bayesian Estimation of Structural Vector Autoregressive Models
Provides fast and efficient procedures for Bayesian analysis of Structural Vector Autoregressions. This package estimates a wide range of models, including homo-, heteroskedastic, and non-normal specifications. Structural models can be identified by adjustable exclusion restrictions, time-varying volatility, or non-normality, and include exclusion restrictions on autoregressive parameters. They all include a flexible three-level equation-specific local-global hierarchical prior distribution for the estimated level of shrinkage for autoregressive and structural parameters. Additionally, the package facilitates predictive and structural analyses such as impulse responses, forecast error variance and historical decompositions, forecasting, verification of heteroskedasticity, non-normality, and hypotheses on autoregressive parameters, as well as analyses of structural shocks, volatilities, and fitted values. Beautiful plots, informative summary functions, and extensive documentation including the vignette by Woźniak (2025) complement all this. The implemented techniques align closely with those presented in Lütkepohl, Shang, Uzeda, & Woźniak (2025), Lütkepohl & Woźniak (2020), and Song & Woźniak (2021) and they embed many popular models proposed by other authors. The ‘bsvars’ package is aligned regarding objects, workflows, and code structure with the R packages ‘bsvarSIGNs’ by Wang & Woźniak (2025), ‘bvars’ by Liu, Ramirez Hassan, Woźniak (2026), and ‘bpvars’ by Woźniak (2026), and they constitute an integrated toolset.
A and error
terms E, and the structural equation with a structural matrix B
and shocks U Y = AX + E (VAR equation)
BE = U (structural equation)
A and the structural matrix B may
include exclusion restrictions and feature a three-level local-global
hierarchical prior that estimates the equation-specific level of
shrinkagespecify_bsvar_* functions, for instance,
specify_bsvar_sv$new()estimate() methodforecast() methodcompute_impulse_responses(),
compute_variance_decompositions(),
compute_historical_decompositions(), and
compute_structural_shocks() respectivelycompute_fitted_values(),
compute_conditional_sd(), and compute_regime_probabilities()
respectivelyplot() and summary() methods to gain the insights into the
core of the empirical problem.verify_identification() and verify_autoregression()**************************************************|
bsvars: Bayesian Structural Vector Autoregressions|
**************************************************|
Gibbs sampler for the SVAR-SV model |
Non-centred SV model is estimated |
**************************************************|
Progress of the MCMC simulation for 1000 draws
Every 10th draw is saved via MCMC thinning
Press Esc to interrupt the computations
**************************************************|
0% 10 20 30 40 50 60 70 80 90 100%
[----|----|----|----|----|----|----|----|----|----|
*************************************
This beautiful logo can be reproduced in R using this file.
The beginnings are as easy as ABC:
library(bsvars) # upload the package
spec = specify_bsvar_sv$new(us_fiscal_lsuw, p = 4) # specify the model
burn_in = estimate(spec, 1000) # run the burn-in
out = estimate(burn_in, 50000) # estimate the model
fore = forecast(out, horizon = 8) # forecast 2 years ahead
plot(fore) # plot the forecast
irfs = compute_impulse_responses(out, 8) # compute impulse responses
plot(irfs) # plot the impulse responses
The bsvars package supports a simplified workflow using the |>
pipe:
library(bsvars) # upload the package
us_fiscal_lsuw |>
specify_bsvar_sv$new(p = 4) |> # specify the model
estimate(S = 1000) |> # run the burn-in
estimate(S = 50000) -> out # estimate the model
out |> forecast(horizon = 8) |> plot() # compute and plot forecasts
out |> compute_impulse_responses(8) |> plot() # compute and plot impulse responses
Now, you’re ready to analyse your model!
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.
Just open your R and type:
install.packages("bsvars")
The developer’s version of the package with the newest features can be installed by typing:
devtools::install_github("bsvars/bsvars")
Your help is most welcome! Contribute by submitting a Pull Request with your code. Contributions that add new functionality require prior agreement with the package authors. We only accept submissions from humans, and AI agents cannot be listed as contributors. This means that the person providing the code takes full responsibility for the contribution. Please also have a look at the roadmap, or report a bug. Thank you!
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.