# This is a function that is used within estimate()
data(us_fiscal_lsuw)
specification = specify_bsvar_sv$new(us_fiscal_lsuw, p = 4)
set.seed(123)
estimate = estimate(specification, 5, thin = 1)
class(estimate)
## ------------------------------------------------
## Method `specify_posterior_bsvar_sv$get_posterior`
## ------------------------------------------------
data(us_fiscal_lsuw)
specification = specify_bsvar_sv$new(us_fiscal_lsuw)
set.seed(123)
estimate = estimate(specification, 5, thin = 1)
estimate$get_posterior()
## ------------------------------------------------
## Method `specify_posterior_bsvar_sv$get_last_draw`
## ------------------------------------------------
data(us_fiscal_lsuw)
# specify the model and set seed
specification = specify_bsvar_sv$new(us_fiscal_lsuw, p = 4)
set.seed(123)
# run the burn-in
burn_in = estimate(specification, 5, thin = 1)
# estimate the model
posterior = estimate(burn_in, 5, thin = 1)
## ------------------------------------------------
## Method `specify_posterior_bsvar_sv$is_normalised`
## ------------------------------------------------
# upload data
data(us_fiscal_lsuw)
# specify the model and set seed
specification = specify_bsvar_sv$new(us_fiscal_lsuw, p = 4)
# estimate the model
set.seed(123)
posterior = estimate(specification, 5, 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((-1) * sign(diag(BB))) %*% BB # set negative diagonal elements
normalise_posterior(posterior, B_hat) # draws in posterior are normalised
# check normalisation status afterwards
posterior$is_normalised()
## ------------------------------------------------
## Method `specify_posterior_bsvar_sv$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_sv$new(us_fiscal_lsuw, p = 4)
# estimate the model
set.seed(123)
posterior = estimate(specification, 5, 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
normalise_posterior(posterior, B_hat) # draws in posterior are normalised
# check normalisation status afterwards
posterior$is_normalised()
Run the code above in your browser using DataLab