specify_posterior_bsvar_mix {bsvars} | R Documentation |
The class PosteriorBSVAR-MIX contains posterior output and the specification including
the last MCMC draw for the bsvar model with a zero-mean mixture of normals model for structural shocks.
Note that due to the thinning of the MCMC output the starting value in element last_draw
might not be equal to the last draw provided in element posterior
.
last_draw
an object of class BSVAR-MIX with the last draw of the current MCMC run as the starting value to be passed to the continuation of the MCMC estimation using bsvar_mix()
.
posterior
a list containing Bayesian estimation output.
new()
Create a new posterior output PosteriorBSVAR-MIX.
specify_posterior_bsvar_mix$new(specification_bsvar, posterior_bsvar)
specification_bsvar
an object of class BSVAR-MIX with the last draw of the current MCMC run as the starting value.
posterior_bsvar
a list containing Bayesian estimation output.
A posterior output PosteriorBSVAR-MIX.
get_posterior()
Returns a list containing Bayesian estimation output.
specify_posterior_bsvar_mix$get_posterior()
data(us_fiscal_lsuw) specification = specify_bsvar_mix$new(us_fiscal_lsuw, M = 2) set.seed(123) estimate = estimate_bsvar_mix(10, specification, thin = 1) estimate$get_posterior()
get_last_draw()
Returns an object of class BSVAR-MIX with the last draw of the current MCMC run as the starting value to be passed to the continuation of the MCMC estimation using bsvar_mix()
.
specify_posterior_bsvar_mix$get_last_draw()
data(us_fiscal_lsuw) # specify the model and set seed specification = specify_bsvar_mix$new(us_fiscal_lsuw, p = 4, M = 2) # run the burn-in set.seed(123) burn_in = estimate_bsvar_mix(10, specification, thin = 2) # get the last draw last_draw = burn_in$get_last_draw() # estimate the model posterior = estimate_bsvar_mix(10, last_draw, thin = 2)
is_normalised()
Returns TRUE
if the posterior has been normalised using normalise_posterior()
and FALSE
otherwise.
specify_posterior_bsvar_mix$is_normalised()
# upload data data(us_fiscal_lsuw) # specify the model and set seed specification = specify_bsvar_mix$new(us_fiscal_lsuw, p = 4, M = 2) # estimate the model set.seed(123) posterior = estimate_bsvar_mix(10, specification, thin = 1) # check normalisation status beforehand posterior$is_normalised() # 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 # check normalisation status afterwards posterior$is_normalised()
set_normalised()
Sets the private indicator normalised
to TRUE.
specify_posterior_bsvar_mix$set_normalised(value)
value
(optional) a logical value to be passed to indicator normalised
.
# This is an internal function that is run while executing normalise_posterior() # Observe its working by analysing the workflow: # upload data data(us_fiscal_lsuw) # specify the model and set seed specification = specify_bsvar$new(us_fiscal_lsuw, p = 4) set.seed(123) # estimate the model posterior = estimate_bsvar(10, specification, thin = 1) # check normalisation status beforehand posterior$is_normalised() # 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 # check normalisation status afterwards posterior$is_normalised()
clone()
The objects of this class are cloneable with this method.
specify_posterior_bsvar_mix$clone(deep = FALSE)
deep
Whether to make a deep clone.
estimate_bsvar_mix
, specify_bsvar_mix
# This is a function that is used within estimate_bsvar()
data(us_fiscal_lsuw)
specification = specify_bsvar_mix$new(us_fiscal_lsuw, p = 4, M = 2)
set.seed(123)
estimate = estimate_bsvar_mix(10, specification, thin = 1)
class(estimate)
## ------------------------------------------------
## Method `specify_posterior_bsvar_mix$get_posterior`
## ------------------------------------------------
data(us_fiscal_lsuw)
specification = specify_bsvar_mix$new(us_fiscal_lsuw, M = 2)
set.seed(123)
estimate = estimate_bsvar_mix(10, specification, thin = 1)
estimate$get_posterior()
## ------------------------------------------------
## Method `specify_posterior_bsvar_mix$get_last_draw`
## ------------------------------------------------
data(us_fiscal_lsuw)
# specify the model and set seed
specification = specify_bsvar_mix$new(us_fiscal_lsuw, p = 4, M = 2)
# run the burn-in
set.seed(123)
burn_in = estimate_bsvar_mix(10, specification, thin = 2)
# get the last draw
last_draw = burn_in$get_last_draw()
# estimate the model
posterior = estimate_bsvar_mix(10, last_draw, thin = 2)
## ------------------------------------------------
## Method `specify_posterior_bsvar_mix$is_normalised`
## ------------------------------------------------
# upload data
data(us_fiscal_lsuw)
# specify the model and set seed
specification = specify_bsvar_mix$new(us_fiscal_lsuw, p = 4, M = 2)
# estimate the model
set.seed(123)
posterior = estimate_bsvar_mix(10, specification, thin = 1)
# check normalisation status beforehand
posterior$is_normalised()
# 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
# check normalisation status afterwards
posterior$is_normalised()
## ------------------------------------------------
## Method `specify_posterior_bsvar_mix$set_normalised`
## ------------------------------------------------
# This is an internal function that is run while executing normalise_posterior()
# Observe its working by analysing the workflow:
# upload data
data(us_fiscal_lsuw)
# specify the model and set seed
specification = specify_bsvar$new(us_fiscal_lsuw, p = 4)
set.seed(123)
# estimate the model
posterior = estimate_bsvar(10, specification, thin = 1)
# check normalisation status beforehand
posterior$is_normalised()
# 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
# check normalisation status afterwards
posterior$is_normalised()