Learn R Programming

bsvarSIGNs (version 2.0)

compute_structural_shocks.PosteriorBSVARSIGN: Computes posterior draws of structural shocks

Description

Each of the draws from the posterior estimation of models from packages bsvars or bsvarSIGNs is transformed into a draw from the posterior distribution of the structural shocks.

Usage

# S3 method for PosteriorBSVARSIGN
compute_structural_shocks(posterior)

Value

An object of class PosteriorShocks, that is, an NxTxS

array with attribute PosteriorShocks containing S draws of the structural shocks.

Arguments

posterior

posterior estimation outcome - an object of class PosteriorBSVARSIGN obtained by running the estimate function.

Author

Xiaolei Wang adamwang15@gmail.com and Tomasz Woźniak wozniak.tom@pm.me

See Also

estimate.BSVARSIGN, summary, plot

Examples

Run this code
# upload data
data(optimism)

# specify the model and set seed
set.seed(123)

# + no effect on productivity (zero restriction)
# + positive effect on stock prices (positive sign restriction) 
sign_irf       = matrix(c(0, 1, rep(NA, 23)), 5, 5)
specification  = specify_bsvarSIGN$new(optimism, sign_irf = sign_irf)

# estimate the model
posterior      = estimate(specification, 10)

# compute structural shocks
shocks         = compute_structural_shocks(posterior)

# workflow with the pipe |>
############################################################
set.seed(123)
optimism |>
  specify_bsvarSIGN$new(sign_irf = sign_irf) |> 
  estimate(S = 20) |> 
  compute_structural_shocks() -> ss

Run the code above in your browser using DataLab