Posterior Draw from a Normal Distribution
Produces a draw of coefficients from a normal posterior density for a model with seemingly unrelated regresssions (SUR).
post_normal_sur(y, z, sigma_i, a_prior, v_i_prior, svd = FALSE)
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. |
svd |
logical. If |
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].
A vector.
# 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)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.