Skip to contents

Estimates homo- or heteroskedastic SVAR models using the Gibbs sampler proposed by Waggoner & Zha (2003) for the structural matrix \(B\) and the equation-by-equation sampler by Chan, Koop, & Yu (2021) for the autoregressive slope parameters \(A\). Additionally, the parameter matrices \(A\) and \(B\) follow a Minnesota prior and generalised-normal prior distributions respectively with the matrix-specific overall shrinkage parameters estimated using a hierarchical prior distribution. A variety of models for conditional variances are possible including versions of Stochastic Volatility and Markov-switching heteroskedasticity. Non-normal specifications include finite and sparse normal mixture model for the structural shocks. See section Details for the model equations.

Usage

estimate(specification, S, thin = 10, show_progress = TRUE)

Arguments

specification

an object of class BSVAR, BSVARMSH, BSVARMIX, or BSVARSV generated using one of the specify_bsvar* functions or an object of class PosteriorBSVAR, PosteriorBSVARMSH, PosteriorBSVARMIX, or PosteriorBSVARSV generated using the function estimate. The latter type of input facilitates the continuation of the MCMC sampling starting from the last draw of the previous run.

S

a positive integer, the number of posterior draws to be generated

thin

a positive integer, specifying the frequency of MCMC output thinning

show_progress

a logical value, if TRUE the estimation progress bar is visible

Value

An object of class PosteriorBSVAR, PosteriorBSVARMSH, PosteriorBSVARMIX, or PosteriorBSVARSV containing the Bayesian estimation output and containing two elements:

posterior a list with a collection of S draws from the posterior distribution generated via Gibbs sampler containing many arrays and vectors whose selection depends on the model specification. last_draw an object of class BSVAR, BSVARMSH, BSVARMIX, or BSVARSV with the last draw of the current MCMC run as the starting value to be passed to the continuation of the MCMC estimation using estimate().

Details

The homoskedastic SVAR model is given by 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.

The structural shocks, U, are temporally and contemporaneously independent and jointly normally distributed with zero mean and unit variances.

The various SVAR models estimated differ by the specification of structural shocks variances. Their specification depends on the specify_bsvar* function used. The different models include:

  • homoskedastic model with unit variances

  • heteroskedastic model with stationary Markov switching in the variances

  • heteroskedastic model with Stochastic Volatility process for variances

  • non-normal model with a finite mixture of normal components and component-specific variances

  • heteroskedastic model with sparse Markov switching in the variances where the number of heteroskedastic components is estimated

  • non-normal model with a sparse mixture of normal components and component-specific variances where the number of heteroskedastic components is estimated

References

Sampling from the generalised-normal full conditional posterior distribution of matrix \(B\) is implemented using the Gibbs sampler by:

Waggoner, D.F., and Zha, T., (2003) A Gibbs sampler for structural vector autoregressions. Journal of Economic Dynamics and Control, 28, 349--366, doi:10.1016/S0165-1889(02)00168-9 .

Sampling from the multivariate normal full conditional posterior distribution of each of the \(A\) matrix row is implemented using the sampler by:

Chan, J.C.C., Koop, G, and Yu, X. (2021) Large Order-Invariant Bayesian VARs with Stochastic Volatility.

Author

Tomasz Woźniak wozniak.tom@pm.me

Examples

# simple workflow
############################################################
# upload data
data(us_fiscal_lsuw)

# specify the model and set seed
specification  = specify_bsvar$new(us_fiscal_lsuw, p = 4)
#> The identification is set to the default option of lower-triangular structural matrix.
set.seed(123)

# run the burn-in
burn_in        = estimate(specification, 50)
#> **************************************************|
#> bsvars: Bayesian Structural Vector Autoregressions|
#> **************************************************|
#>  Gibbs sampler for the SVAR model                 |
#> **************************************************|
#>  Progress of the MCMC simulation for 50 draws
#>     Every 10th draw is saved via MCMC thinning
#>  Press Esc to interrupt the computations
#> **************************************************|

# estimate the model
posterior      = estimate(burn_in, 100)
#> **************************************************|
#> bsvars: Bayesian Structural Vector Autoregressions|
#> **************************************************|
#>  Gibbs sampler for the SVAR model                 |
#> **************************************************|
#>  Progress of the MCMC simulation for 100 draws
#>     Every 10th draw is saved via MCMC thinning
#>  Press Esc to interrupt the computations
#> **************************************************|

# workflow with the pipe |>
############################################################
set.seed(123)
us_fiscal_lsuw |>
  specify_bsvar$new(p = 1) |>
  estimate(S = 50) |> 
  estimate(S = 100) |> 
  compute_impulse_responses(horizon = 8) -> irf
#> The identification is set to the default option of lower-triangular structural matrix.
#> **************************************************|
#> bsvars: Bayesian Structural Vector Autoregressions|
#> **************************************************|
#>  Gibbs sampler for the SVAR model                 |
#> **************************************************|
#>  Progress of the MCMC simulation for 50 draws
#>     Every 10th draw is saved via MCMC thinning
#>  Press Esc to interrupt the computations
#> **************************************************|
#> **************************************************|
#> bsvars: Bayesian Structural Vector Autoregressions|
#> **************************************************|
#>  Gibbs sampler for the SVAR model                 |
#> **************************************************|
#>  Progress of the MCMC simulation for 100 draws
#>     Every 10th draw is saved via MCMC thinning
#>  Press Esc to interrupt the computations
#> **************************************************|