| bsvars-package | R Documentation |
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) <doi:10.48550/arXiv.2410.15090> complement all this. The implemented techniques align closely with those presented in Lütkepohl, Shang, Uzeda, & Woźniak (2025) <doi:10.1016/j.jeconom.2025.106107>, Lütkepohl & Woźniak (2020) <doi:10.1016/j.jedc.2020.103862>, and Song & Woźniak (2021) <doi:10.1093/acrefore/9780190625979.013.174> 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) <doi:10.32614/CRAN.package.bsvarSIGNs>, 'bvars' by Liu, Ramirez Hassan, Woźniak (2026) <doi:10.32614/CRAN.package.bvars>, and 'bpvars' by Woźniak (2026) <doi:10.32614/CRAN.package.bpvars>, and they constitute an integrated toolset.
Models. All the SVAR models in this package are specified by two equations, including the reduced form equation:
Y = AX + E
where Y is an NxT matrix of dependent variables,
X is a KxT matrix of explanatory variables,
E is an NxT matrix of reduced form error terms,
and A is an NxK matrix of autoregressive slope coefficients and
parameters on deterministic terms in X.
The structural equation is given by:
BE = U
where U is an NxT matrix of structural form error terms, and
B is an NxN matrix of contemporaneous relationships.
Finally, all of the models share assumptions regarding the structural
shocks U, namely, temporal and contemporaneous independence. They imply
zero correlations and autocorrelations.
The various SVAR models estimated differ by the specification of structural shocks variances. The different models include:
homoskedastic model with unit variances
heteroskedastic model with non-centred Stochastic Volatility process for variances
heteroskedastic model with centred Stochastic Volatility process for variances
heteroskedastic model with stationary Markov switching in the variances
heteroskedastic model with sparse Markov switching in the variances where the number of heteroskedastic components is estimated
heteroskedastic model with stationary heterogeneous Markov switching in the variances, where each shock volatility has its own Markov process
heteroskedastic model with sparse heterogeneous Markov switching in the variances where the number of heteroskedastic components is estimated
heteroskedastic model with exogenous heteroskedastic regime changes in the variances
a model with Student-t distributed structural shocks with estimated equation-specific degrees-of-freedom parameter
non-normal model with a finite mixture of normal components and component-specific variances
non-normal model with a sparse mixture of normal components and component-specific variances where the number of heteroskedastic components is estimated
The structural shocks can be either normally or Student-t distributed, where in the latter case the shock-specific degrees of freedom parameters are estimated.
Prior distributions. All the models feature a Minnesota prior for autoregressive
parameters in matrix A and a generalised-normal distribution for the structural
matrix B. Both of these distributions feature a 3-level equation-specific
local-global hierarchical prior that make the shrinkage estimation flexible improving
the model fit and its forecasting performance.
Estimation algorithm. The models are estimated using frontier numerical methods making the Gibbs sampler fast and efficient. The estimation follows closely Lütkepohl, Shang, Uzeda, & Woźniak (2025). The sampler of the structural matrix follows Waggoner & Zha (2003), whereas that for autoregressive parameters follows Chan, Koop, Yu (2022). The specification of Markov switching heteroskedasticity is inspired by Song & Woźniak (2021), and that of Stochastic Volatility model by Kastner & Frühwirth-Schnatter (2014). The identification problems are considered in Lütkepohl, Shang, Uzeda, & Woźniak (2025) and Lütkepohl & Woźniak (2020).
Identification verification. The structural shocks can be identified through heteroskedasticity or non-normality following Lütkepohl, Shang, Uzeda, & Woźniak (2025) and Lütkepohl & Woźniak (2020). The package provides functions to verify both, homoskedasticity and normality of the structural shocks, which facilitates making probabilistic statements regarding the identification. Additionally, the package makes it possible to verify linear restrictions on autoregressive parameters.
This package is currently in active development. Your comments, suggestions and requests are warmly welcome!
Tomasz Woźniak wozniak.tom@pm.me
Chan, J.C.C., Koop, G, and Yu, X. (2024) Large Order-Invariant Bayesian VARs with Stochastic Volatility. Journal of Business & Economic Statistics, 42, \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1080/07350015.2023.2252039")}.
Kastner, G. and Frühwirth-Schnatter, S. (2014) Ancillarity-Sufficiency Interweaving Strategy (ASIS) for Boosting MCMC Estimation of Stochastic Volatility Models. Computational Statistics & Data Analysis, 76, 408–423, \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1016/j.csda.2013.01.002")}.
Liu, Ramirez Hassan, Woźniak (2026) bvars: Bayesian Forecasting with Large Vector Autoregressions. R package version 1.0, \Sexpr[results=rd]{tools:::Rd_expr_doi("10.32614/CRAN.package.bvars")}.
Lütkepohl, H., Shang, F., Uzeda, L., and Woźniak, T. (2025) Partial identification of structural vector autoregressions with non-centred stochastic volatility. Journal of Econometrics 256, 106107, \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1016/j.jeconom.2025.106107")}.
Lütkepohl, H., and Woźniak, T., (2020) Bayesian Inference for Structural Vector Autoregressions Identified by Markov-Switching Heteroskedasticity. Journal of Economic Dynamics and Control 113, 103862, \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1016/j.jedc.2020.103862")}.
Song, Y., and Woźniak, T. (2021) Markov Switching Heteroskedasticity in Time Series Analysis. In: Oxford Research Encyclopedia of Economics and Finance. Oxford University Press, \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1093/acrefore/9780190625979.013.174")}.
Waggoner, D.F., and Zha, T., (2003) A Gibbs sampler for structural vector autoregressions. Journal of Economic Dynamics and Control, 28, 349–366, \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1016/S0165-1889(02)00168-9")}.
Wang X, Woźniak T (2025). bsvarSIGNs: Bayesian SVARs with Sign, Zero, and Narrative Restrictions. R package version 2.0, \Sexpr[results=rd]{tools:::Rd_expr_doi("10.32614/CRAN.package.bsvarSIGNs")}.
Woźniak T (2026) bpvars: Forecasting with Bayesian Panel Vector Autoregressions. R package version 2.0, \Sexpr[results=rd]{tools:::Rd_expr_doi("10.32614/CRAN.package.bpvars")}.
Useful links:
spec = specify_bsvar_sv$new( # specify the model
us_fiscal_lsuw,
exogenous = us_fiscal_ex
)
burn = estimate(spec, 5) # run the burn-in
post = estimate(burn, 5) # estimate the model
irf = compute_impulse_responses( # compute impulse responses
post,
horizon = 2
)
# compute forecast error variance decomposition one year ahead
fevd = compute_variance_decompositions(post, horizon = 4)
# workflow with the pipe |>
############################################################
us_fiscal_lsuw |>
specify_bsvar_sv$new(exogenous = us_fiscal_ex) |>
estimate(S = 5) |>
estimate(S = 5) |>
compute_variance_decompositions(horizon = 4) -> fevds
# conditional forecasting using a model with exogenous variables
############################################################
us_fiscal_lsuw |>
specify_bsvar_sv$new(exogenous = us_fiscal_ex) |>
estimate(S = 5) |>
estimate(S = 5) -> post
post |> forecast(
horizon = 8,
exogenous_forecast = us_fiscal_ex_forecasts,
conditional_forecast = us_fiscal_cond_forecasts
) -> pred
pred |> summary()
pred |> plot(probability = 0.68)
# estimation of a model with exogeneity restrictions on the autoregressive matrix
#############################################################
A = matrix(TRUE, 3, 7)
A[1,3] = A[1,6] = FALSE
us_fiscal_lsuw |>
specify_bsvar_sv$new(p = 2, A = A) |>
estimate(S = 5) |>
estimate(S = 5) -> post
post |> summary()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.