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 K×TK \times T matrix of endogenous variables.

x

an M×TM \times T matrix of explanatory variables.

sigma_i

the inverse of the K×KK \times K variance-covariance matrix.

a_prior

a KM×1KM \times 1 numeric vector of prior means.

v_i_prior

the inverse of the KM×KMKM \times KM prior covariance matrix.

Details

The function produces a vectorised posterior draw aa of the K×MK \times M coefficient matrix AA for the model

yt=Axt+ut,y_{t} = A x_{t} + u_{t},

where yty_{t} is a K-dimensional vector of endogenous variables, xtx_{t} is an M-dimensional vector of explanatory variabes and the error term is utΣu_t \sim \Sigma.

For a given prior mean vector a\underline{a} and prior covariance matrix V\underline{V} the posterior covariance matrix is obtained by

V=[V1+(XXΣ1)]1\overline{V} = \left[ \underline{V}^{-1} + \left(X X^{\prime} \otimes \Sigma^{-1} \right) \right]^{-1}

and the posterior mean by

a=V[V1a+vec(Σ1YX)],\overline{a} = \overline{V} \left[ \underline{V}^{-1} \underline{a} + vec(\Sigma^{-1} Y X^{\prime}) \right],

where YY is a K×TK \times T matrix of the endogenous variables and XX is an M×TM \times T 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)


[Package bvartools version 0.2.4 Index]