specify_posterior_bsvar function

R6 Class Representing PosteriorBSVAR

R6 Class Representing PosteriorBSVAR

The class PosteriorBSVAR contains posterior output and the specification including the last MCMC draw for the homoskedastic bsvar model. 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.

Examples

# This is a function that is used within estimate() data(us_fiscal_lsuw) specification = specify_bsvar$new(us_fiscal_lsuw, p = 4) set.seed(123) estimate = estimate(specification, 50) class(estimate) ## ------------------------------------------------ ## Method `specify_posterior_bsvar$get_posterior` ## ------------------------------------------------ data(us_fiscal_lsuw) specification = specify_bsvar$new(us_fiscal_lsuw) set.seed(123) estimate = estimate(specification, 50) estimate$get_posterior() ## ------------------------------------------------ ## Method `specify_posterior_bsvar$get_last_draw` ## ------------------------------------------------ data(us_fiscal_lsuw) # specify the model and set seed specification = specify_bsvar$new(us_fiscal_lsuw, p = 4) set.seed(123) # run the burn-in burn_in = estimate(specification, 10) # estimate the model posterior = estimate(burn_in, 10) ## ------------------------------------------------ ## Method `specify_posterior_bsvar$is_normalised` ## ------------------------------------------------ # 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(specification, 10, 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$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(specification, 10, 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()

See Also

estimate, specify_bsvar

Public fields

  • last_draw: an object of class BSVAR with the last draw of the current MCMC run as the starting value to be passed to the continuation of the MCMC estimation using estimate().

  • posterior: a list containing Bayesian estimation output collected in elements an NxNxS array B, an NxKxS array A, and a 5xS matrix hyper.

Methods

Public methods

Method new()

Create a new posterior output PosteriorBSVAR.

Usage

specify_posterior_bsvar$new(specification_bsvar, posterior_bsvar)

Arguments

  • specification_bsvar: an object of class BSVAR with the last draw of the current MCMC run as the starting value.

  • posterior_bsvar: a list containing Bayesian estimation output collected in elements an NxNxS array B, an NxKxS array A, and a 5xS matrix hyper.

Returns

A posterior output PosteriorBSVAR.

Method get_posterior()

Returns a list containing Bayesian estimation output collected in elements an NxNxS array B, an NxKxS array A, and a 5xS matrix hyper.

Usage

specify_posterior_bsvar$get_posterior()

Examples

data(us_fiscal_lsuw)
specification  = specify_bsvar$new(us_fiscal_lsuw)
set.seed(123)
estimate       = estimate(specification, 50)
estimate$get_posterior()

Method get_last_draw()

Returns an object of class BSVAR with the last draw of the current MCMC run as the starting value to be passed to the continuation of the MCMC estimation using estimate().

Usage

specify_posterior_bsvar$get_last_draw()

Examples

data(us_fiscal_lsuw)

# specify the model and set seed
specification  = specify_bsvar$new(us_fiscal_lsuw, p = 4)
set.seed(123)

# run the burn-in
burn_in        = estimate(specification, 10)

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

Method is_normalised()

Returns TRUE if the posterior has been normalised using normalise_posterior()

and FALSE otherwise.

Usage

specify_posterior_bsvar$is_normalised()

Examples

# 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(specification, 10, 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 set_normalised()

Sets the private indicator normalised to TRUE.

Usage

specify_posterior_bsvar$set_normalised(value)

Arguments

  • value: (optional) a logical value to be passed to indicator normalised.

Examples

# 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(specification, 10, 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()

Method clone()

The objects of this class are cloneable with this method.

Usage

specify_posterior_bsvar$clone(deep = FALSE)

Arguments

  • deep: Whether to make a deep clone.

  • Maintainer: Tomasz Woźniak
  • License: GPL (>= 3)
  • Last published: 2024-10-24