post_gamma_measurement_variance | R Documentation |
Produces a draw of the constant diagonal error variance matrix of the measurement equation of a state space model using an inverse gamma posterior density.
post_gamma_measurement_variance(u, shape_prior, rate_prior, inverse)
u |
a |
shape_prior |
a |
rate_prior |
a |
inverse |
logical. If |
For a model with measurement equation
y_t = Z_{t} a_t + u_t
with u_t \sim N(0, \Sigma_{u})
the function produces a draw of the constant diagonal error variance matrix
\Simga_u
.
A matrix.
Chan, J., Koop, G., Poirier, D. J., & Tobias J. L. (2019). Bayesian econometric methods (2nd ed.). Cambridge: Cambridge University Press.
k <- 10 # Number of endogenous variables
tt <- 1000 # Number of observations
set.seed(1234) # Set RNG seed
# Generate artificial error series with N(0, 1)
u <- matrix(rnorm(k * tt))
# Define priors
shape_prior <- matrix(1, k)
rate_prior <- matrix(.0001, k)
# Obtain posterior draw
post_gamma_measurement_variance(u, shape_prior, rate_prior, inverse = FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.