bsvars-package {bsvars}R Documentation

Bayesian Estimation of Structural Vector Autoregressive Models


Efficient and fast algorithms for Bayesian estimation of Structural Vector Autoregressive (SVAR) models via Markov chain Monte Carlo methods. A wide range of SVAR models is considered, including homo- and heteroskedastic specifications and those with non-normal structural shocks. The heteroskedastic SVAR model setup is similar as in Woźniak & Droumaguet (2015) <doi:10.13140/RG.2.2.19492.55687> and Lütkepohl & Woźniak (2020) <doi:10.1016/j.jedc.2020.103862>. The sampler of the structural matrix follows Waggoner & Zha (2003) ,doi:10.1016/S0165-1889(02)00168-9>, whereas that for autoregressive parameters follows Chan, Koop, Yu (2022) <>. The specification of Markov switching heteroskedasticity is inspired by Song & Woźniak (2021) <doi:10.1093/acrefore/9780190625979.013.174>, and that of Stochastic Volatility model by Kastner & Frühwirth-Schnatter (2014) <doi:10.1016/j.csda.2013.01.002>.


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 the following assumptions regarding the structural shocks U, namely, joint conditional normality given the past observations collected in matrix X, and temporal and contemporaneous independence. The latter implies zero correlations and autocorrelations.

The various SVAR models estimated differ by the specification of structural shocks variances. The different models include:


This package is currently in active development. Your comments, suggestions and requests are warmly welcome!


Tomasz Woźniak


Woźniak, T., and Droumaguet, M., (2022) Bayesian Assessment of Identifying Restrictions for Heteroskedastic Structural VARs.


# upload data

# specify the model and set seed
specification  = specify_bsvar_sv$new(us_fiscal_lsuw, p = 4)

# run the burn-in
burn_in        = estimate_bsvar_sv(10, specification)

# estimate the model
posterior      = estimate_bsvar_sv(50, burn_in$get_last_draw())

# normalise the posterior
BB            = posterior$last_draw$starting_values$B      # get the last draw of B
B_hat         = diag(sign(diag(BB))) %*% BB                # set positive diagonal elements
bsvars::normalise_posterior(posterior, B_hat)              # draws in posterior are normalised

[Package bsvars version 1.0.0 Index]