Estimates the Bayesian Hierarchical VARs for cubic data using the Gibbs sampler proposed by Sanchez-Martinez & Woźniak (2024).
# S3 method for BVARs
estimate(specification, S, thin = 1L, show_progress = TRUE)An object of class PosteriorBVARs containing the Bayesian
estimation output and containing two elements:
posteriora list with a collection of S draws from the
posterior distribution generated via Gibbs sampler. Elements of the list
correspond to the parameters of the model listed in section Details
and are named respectively:
A_c, Sigma_c, nu, m, w, s.
last_drawan object of class BVARs with the last draw of the
current MCMC run as the starting value to be passed to the continuation of
the MCMC estimation using the estimate() method.
an object of class BVARs generated using the
specify_bvars$new() function.
a positive integer, the number of posterior draws to be generated
a positive integer, specifying the frequency of MCMC output thinning
a logical value, if TRUE the estimation progress
bar is visible
Tomasz Woźniak wozniak.tom@pm.me
The Bayesian Hierarchical Vector Autoregressive models described in
bpvars is estimated using the Gibbs sampler. In this
estimation procedure all the parameters of the model are estimated jointly.
The list of parameters of the model includes:
a KxN country-specific autoregressive
parameters matrix for each of the countries \(c = 1,\dots,C\)
an NxN country-specific covariance
matrix for each of the countries \(c = 1,\dots,C\)
prior degrees of freedom parameter
prior average global persistence parameter
prior scaling parameter
prior scaling parameter
Gibbs sampler is an algorithm to sample random draws from the posterior distribution of the parameters of the model given the data. The algorithm is briefly explained on an example of a two-parameter model with parameters \(\theta_1\) and \(\theta_2\). In order to sample from the joint posterior distribution \(p(\theta_1,\theta_2|\mathbf{Y})\) the Gibbs sampler proceeds by sampling from full-conditional posterior distributions of each parameter given data and all the other parameters, denoted by \(p(\theta_1|\theta_2,\mathbf{Y})\) and \(p(\theta_2|\theta_1,\mathbf{Y})\). These distributions are available from derivations and should be in a form of distributions that are easy to sample random numbers from.
To obtain S draws from the posterior distribution:
Set the initial values of the parameters \(\theta_2^{(0)}\)
At each of the s iterations:
Sample \(\theta_1^{(s)}\) from \(p(\theta_1|\theta_2^{(s-1)},\mathbf{Y})\)
Sample \(\theta_2^{(s)}\) from \(p(\theta_2|\theta_1^{(s)},\mathbf{Y})\)
Repeat step 2. S times. Return \(\{\theta_1^{(s)},\theta_2^{(s)}\}_{s=1}^{S}\)
as a sample drawn from the posterior distribution \(p(\theta_1,\theta_2|\mathbf{Y})\).
The estimate() function returns the draws from the posterior distribution
of the parameters of the hierarchical VAR model listed above.
Thinning.
Thinning is a procedure to reduce the dependence in the returned sample from
the posterior distribution. It is obtained by returning every thin
draw in the final sample. This procedure reduces the number of draws returned
by the estimate() function.
bpvars, specify_bvars,
specify_posterior_bvars, summary.PosteriorBVARs,
forecast.PosteriorBVARs
# specify the model
specification = specify_bvars$new(
ilo_dynamic_panel[1:5],
exogenous = ilo_exogenous_variables[1:5]
)
burn_in = estimate(specification, 10) # run the burn-in; use say S = 10000
posterior = estimate(burn_in, 10) # estimate the model; use say S = 10000
Run the code above in your browser using DataLab