post_normal_sur {bvartools} | R Documentation |
Posterior Draw from a Normal Distribution
Description
Produces a draw of coefficients from a normal posterior density for a model with seemingly unrelated regresssions (SUR).
Usage
post_normal_sur(y, z, sigma_i, a_prior, v_i_prior, svd = FALSE)
Arguments
y |
a |
z |
a |
sigma_i |
the inverse of the constant |
a_prior |
a |
v_i_prior |
the inverse of the |
svd |
logical. If |
Details
The function produces a posterior draw of the coefficient vector a
for the model
y_{t} = Z_{t} a + u_{t},
where u_t \sim N(0, \Sigma_{t})
.
y_t
is a K-dimensional vector of endogenous variables and
Z_t = z_t^{\prime} \otimes I_K
is a K \times KM
matrix of regressors with
z_t
as a vector of regressors.
For a given prior mean vector \underline{a}
and prior covariance matrix \underline{V}
the posterior covariance matrix is obtained by
\overline{V} = \left[ \underline{V}^{-1} + \sum_{t=1}^{T} Z_{t}^{\prime} \Sigma_{t}^{-1} Z_{t} \right]^{-1}
and the posterior mean by
\overline{a} = \overline{V} \left[ \underline{V}^{-1} \underline{a} + \sum_{t=1}^{T} Z_{t}^{\prime} \Sigma_{t}^{-1} y_{t} \right].
Value
A vector.
Examples
# Load data
data("e1")
data <- diff(log(e1))
# Generate model data
temp <- gen_var(data, p = 2, deterministic = "const")
y <- t(temp$data$Y)
z <- temp$data$SUR
k <- nrow(y)
tt <- ncol(y)
m <- ncol(z)
# Priors
a_mu_prior <- matrix(0, m)
a_v_i_prior <- diag(0.1, m)
# Initial value of inverse Sigma
sigma_i <- solve(tcrossprod(y) / tt)
# Draw parameters
a <- post_normal_sur(y = y, z = z, sigma_i = sigma_i,
a_prior = a_mu_prior, v_i_prior = a_v_i_prior)