BVAR with Minnesota prior.
Instantiation:
# create a new object bvar_obj <- new(bvarm)
Fields:
cons_term
a logical value (TRUE/FALSE) indicating the presence of a constant term (intercept) in the model.p
lag order (integer).var_type
variance type (1 or 2); see below for more details.decay_type
decay type (1 or 2) for the var_type=2
case.c_int
integer version of cons_term
.n
sample length.M
number of variables.n_ext_vars
number of exogenous variables.K
number of right-hand-side terms in each equation.Y
a $(n-p) \times M$ data matrix.X
a $(n-p) \times K$ data matrix.alpha_hat
OLS estimate of $\alpha = \text{vec}(\beta)$.Sigma_hat
OLS estimate of $\Sigma$.alpha_pr_mean
prior mean of $\alpha = \text{vec}(\beta)$.alpha_pr_var
prior covariance matrix of $\alpha = \text{vec}(\beta)$.alpha_pt_mean
posterior mean of $\alpha = \text{vec}(\beta)$.alpha_pt_var
posterior covariance matrix of $\alpha = \text{vec}(\beta)$.beta_draws
an array of posterior draws for $\beta$.Build:
bvar_obj$build(data_endog,cons_term,p) bvar_obj$build(data_endog,data_exog,cons_term,p)
data_endog
a $n \times M$ matrix of endogenous varibles.data_exog
a $n \times q$ matrix of exogenous varibles.cons_term
a logical value (TRUE/FALSE) indicating the presence of a constant term (intercept) in the model.p
lag order (integer).Prior:
bvar_obj$prior(coef_prior) bvar_obj$prior(coef_prior,var_type,decay_type,HP_1,HP_2,HP_3,HP_4)
coef_prior
a $m \times 1$ vector containing the prior mean for each first own-lag coefficient.var_type
variance type (1 or 2); see below for more details.decay_type
decay type (1 or 2) for the var_type=2
case.HP_1,HP_2,HP_3,HP_4
hyperparameters; see below for more details.Gibbs sampling:
bvar_obj$gibbs(n_draws)
n_draws
number of posterior draws.The model:
$$ y_t = \beta_0 + y_{t-1} \beta_1 + \cdots y_{t-p} \beta_p + e_t, \ \ e_t \stackrel{\text{iid}}{\sim} \mathcal{N} \left( \mathbf{0}, \Sigma \right) $$where $y_t$ is a $1 \times M$ vector. We write this in stacked form as:
$$ Y = X \beta + e $$The Minnesota prior (also known as Litterman's prior) holds $\Sigma$ fixed to a data-based estimate for posterior sampling of $\beta$, a simplification that yields significant computational speedups compared with the independent Normal-inverse-Wishart model. For references, see Doan, Litterman, and Sims (1983) and Litterman (1986).
With the Minnesota prior, $\Sigma$ is a diagonal matrix whose elements are derived from equation-by-equation estimation of AR($p$) models, one for each variable in the VAR system. That is, for each variable in the VAR model, we estimate the model imposing that all coefficients, except own-lag terms (and a possible constant), are equal to zero. Then:
$$
\Sigma = \begin{bmatrix} \sigma_{1}^2 &0 & 0 & \cdots & 0 \\ 0& \sigma_2^2 & 0 & \cdots & 0 \\ 0& 0 & \sigma_3^2 & \ddots & 0 \\ \vdots & \vdots & \ddots & \ddots & \vdots \\ 0& 0 & 0 & 0 & \sigma_M^2 \end{bmatrix}
$$
The prior for $\alpha = \text{vec}(\beta)$ is:
$$ p(\alpha) = \mathcal{N}(\bar{\alpha},\Xi_\alpha) $$The prior mean of the coefficients, $\bar{\alpha}$, is a $K M \times 1$ vector of zeros, except for elements that relate to the fist-order own-lags terms. The latter values are set by coef_prior
the prior function.
Construction of the prior variance matrix for $\beta$ is set in one of two ways.
var_type=1
Koop and Korobilis (2010) version of the prior covariance matrix for $\beta$:
\begin{equation*}
\Xi_{\beta_{i,j}} (\ell) =
\begin{cases}
&H_1 / \ell^2 \\
& H_2 \cdot \sigma_{i}^2 / \left( \ell^2 \cdot \sigma_{j}^2 \right) \\
& H_3 \cdot \sigma_{i}^2
\end{cases}
\end{equation*}
which correspond to own lags, cross-variable lags, and exogenous variables (e.g., a constant), respectively.var_type=2
Canova (2007) uses a general form for the decay:
\begin{equation*}
\Xi_{\beta_{i,j}} (\ell) =
\begin{cases}
& H_1 / d(\ell) \\
& H_1 \cdot H_2 \cdot \sigma_{j}^2 / \left( d(\ell) \cdot \sigma_{i}^2 \right) \\
& H_1 \cdot H_3
\end{cases}
\end{equation*}
which, again, correspond to own lags, cross-variable lags, and exogenous variables, respectively. $d(\ell)$ is the decay function.
decay_type=1
harmonic decay, where $d (\ell) = \ell^{H_4}$;decay_type=2
geometric decay, where $d (\ell) = H_4^{-\ell + 1}$.$\Xi_{\beta}$ is then vectorised and becomes the main diagonal of $\Xi_\alpha$, with all off-diagonal elemnts of $\Xi_\alpha$ set to zero.
With $\Sigma$ fixed, the posterior distribution of $\alpha = \text{vec}(\beta)$ is given by \begin{equation} p(\alpha | \Sigma,X,Y) = \mathcal{N} \left( \widetilde{\alpha}, \widetilde{\Sigma}_{\alpha} \right), \end{equation} where \begin{align*} \widetilde{\Sigma}_{\alpha}^{-1} &= \Xi_{\alpha}^{-1} + (\Sigma^{-1} \otimes X^{\top} X) \\ \widetilde{\alpha} &= \widetilde{\Sigma}_{\alpha} \left( \Xi_{\alpha}^{-1} \bar{\alpha} + \text{vec}(X^{\top} Y \Sigma^{-1}) \right) \end{align*}
rm(list=ls()) library(BMR) # data(BMRVARData) bvar_data <- data.matrix(USMacroData[,2:4]) # coef_prior <- c(0.9,0.9,0.9) bvar_obj <- new(bvarm) # bvar_obj$build(bvar_data,TRUE,4) bvar_obj$prior(coef_prior,1,1,0.5,0.5,100.0,1.0) bvar_obj$gibbs(10000) IRF(bvar_obj,20,var_names=colnames(USMacroData),save=FALSE) plot(bvar_obj,var_names=colnames(USMacroData),save=FALSE) forecast(bvar_obj,shocks=TRUE,var_names=colnames(USMacroData),back_data=10,save=FALSE)