
Computes posterior draws of the forecast error variance decomposition
Source:R/compute_variance_decompositions.PosteriorBVARPANEL.R
compute_variance_decompositions.PosteriorBVARPANEL.Rd
For each country, each of the draws from the posterior estimation of the model is transformed into a draw from the posterior distribution of the forecast error variance decomposition.
Usage
# S3 method for class 'PosteriorBVARPANEL'
compute_variance_decompositions(posterior, horizon)
Value
An object of class PosteriorFEVDPANEL
, that is, a list with
C
elements containing NxNx(horizon+1)xS
arrays of class
PosteriorFEVD
with S
draws of country-specific forecast error
variance decompositions.
References
Lütkepohl, H. (2017). Structural VAR Tools, Chapter 4, In: Structural vector autoregressive analysis. Cambridge University Press.
Author
Tomasz Woźniak wozniak.tom@pm.me
Examples
# upload data
data(ilo_dynamic_panel)
# specify the model and set seed
set.seed(123)
specification = specify_bvarPANEL$new(ilo_dynamic_panel, p = 1)
# run the burn-in
burn_in = estimate(specification, 10)
#> **************************************************|
#> bvarPANELs: Forecasting with Bayesian Hierarchical|
#> Panel Vector Autoregressions |
#> **************************************************|
#> Progress of the MCMC simulation for 10 draws
#> Every draw is saved via MCMC thinning
#> Press Esc to interrupt the computations
#> **************************************************|
# estimate the model
posterior = estimate(burn_in, 20)
#> **************************************************|
#> bvarPANELs: Forecasting with Bayesian Hierarchical|
#> Panel Vector Autoregressions |
#> **************************************************|
#> Progress of the MCMC simulation for 20 draws
#> Every draw is saved via MCMC thinning
#> Press Esc to interrupt the computations
#> **************************************************|
# compute forecast error variance decomposition 4 years ahead
fevd = compute_variance_decompositions(posterior, horizon = 4)
# workflow with the pipe |>
############################################################
set.seed(123)
ilo_dynamic_panel |>
specify_bvarPANEL$new(p = 1) |>
estimate(S = 10) |>
estimate(S = 20) |>
compute_variance_decompositions(horizon = 4) -> fevd
#> **************************************************|
#> bvarPANELs: Forecasting with Bayesian Hierarchical|
#> Panel Vector Autoregressions |
#> **************************************************|
#> Progress of the MCMC simulation for 10 draws
#> Every draw is saved via MCMC thinning
#> Press Esc to interrupt the computations
#> **************************************************|
#> **************************************************|
#> bvarPANELs: Forecasting with Bayesian Hierarchical|
#> Panel Vector Autoregressions |
#> **************************************************|
#> Progress of the MCMC simulation for 20 draws
#> Every draw is saved via MCMC thinning
#> Press Esc to interrupt the computations
#> **************************************************|