post_normal {bvartools} | R Documentation |
Posterior Draw from a Normal Distribution
Description
Produces a draw of coefficients from a normal posterior density.
Usage
post_normal(y, x, sigma_i, a_prior, v_i_prior)
Arguments
y |
a |
x |
an |
sigma_i |
the inverse of the |
a_prior |
a |
v_i_prior |
the inverse of the |
Details
The function produces a vectorised posterior draw of the
coefficient matrix
for the model
where is a K-dimensional vector of endogenous variables,
is an M-dimensional vector of explanatory variabes
and the error term is
.
For a given prior mean vector and prior covariance matrix
the posterior covariance matrix is obtained by
and the posterior mean by
where is a
matrix of the endogenous variables and
is an
matrix of
the explanatory variables.
Value
A vector.
References
Lütkepohl, H. (2006). New introduction to multiple time series analysis (2nd ed.). Berlin: Springer.
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)
x <- t(temp$data$Z)
k <- nrow(y)
tt <- ncol(y)
m <- k * nrow(x)
# 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(y = y, x = x, sigma_i = sigma_i,
a_prior = a_mu_prior, v_i_prior = a_v_i_prior)