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)

Arguments

y

a K \times T matrix of endogenous variables.

z

a KT \times M matrix of explanatory variables.

sigma_i

the inverse of the constant K \times K error variance-covariance matrix. For time varying variance-covariance matrics a KT \times K can be provided.

a_prior

a M x 1 numeric vector of prior means.

v_i_prior

the inverse of the M x M prior covariance matrix.

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, Σ_{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} = ≤ft[ \underline{V}^{-1} + ∑_{t=1}^{T} Z_{t}^{\prime} Σ_{t}^{-1} Z_{t} \right]^{-1}

and the posterior mean by

\overline{a} = \overline{V} ≤ft[ \underline{V}^{-1} \underline{a} + ∑_{t=1}^{T} Z_{t}^{\prime} Σ_{t}^{-1} y_{t} \right].

Value

A vector.

Examples

# Prepare data
data("e1")
data <- diff(log(e1))
temp <- gen_var(data, p = 2, deterministic = "const")
y <- temp$Y
x <- temp$Z
k <- nrow(y)
z <- kronecker(t(x), diag(1, k))
t <- 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) / t)

# 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)


[Package bvartools version 0.0.2 Index]