bvartools (version 0.0.1)

ssvs: Stochastic Search Variable Selection

Description

ssvs employs stochastic search variable selection as proposed by George et al. (2008) to produce a draw of the precision matrix of the coefficients in a VAR model.

Usage

ssvs(a, tau0, tau1, prob_prior, include = NULL)

Arguments

a

an M-dimensional vector of coefficient draws.

tau0

an M-dimensional vector of prior standard deviations for restricted variables.

tau1

an M-dimensional vector of prior standard deviations for unrestricted variables.

prob_prior

an M-dimensional vector of prior inclusion probabilites.

include

an integer vector specifying the positions of variables, which should be included in the SSVS algorithm. If NULL (default), SSVS will be applied to all variables.

Value

A named list containing two components:

V_i

an \(M \times M\) inverse prior covariance matrix.

lambda

an M-dimensional vector of inclusion parameters.

Details

The function employs stochastic search variable selection (SSVS) as proposed by George et al. (2008) to produce a draw of the diagonal inverse prior covariance matrix \(\underline{V}^{-1}\) and the corresponding vector of inclusion parameters \(\lambda\) of the vectorised coefficient matrix \(a = vec(A)\) for the VAR model $$y_t = A x_t + u_t,$$ where \(y_{t}\) is a K-dimensional vector of endogenous variables, \(x_{t}\) is a vector of explanatory variabes and the error term is \(u_t \sim \Sigma\).

References

George, E. I., Sun, D., & Ni, S. (2008). Bayesian stochastic search for VAR model restrictions. Journal of Econometrics, 142(1), 553--580. https://doi.org/10.1016/j.jeconom.2007.08.017

Examples

Run this code
# NOT RUN {
# 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)
t <- ncol(y)
m <- k * nrow(x)

# OLS estimates for semiautomatic approach
ols <- tcrossprod(y, x) %*% solve(tcrossprod(x))
# OLS error covariance matrix
sigma_ols <- tcrossprod(y - ols %*% x) / (t - nrow(x))
# Covariance matrix
cov_ols <- kronecker(solve(tcrossprod(x)), sigma_ols)
# Standard errors
se_ols <- matrix(sqrt(diag(cov_ols))) # OLS standard errors

# SSVS priors
tau0 <- se_ols * 0.1 # If excluded
tau1 <- se_ols * 10 # If included

# Prior for inclusion parameter
prob_prior <- matrix(0.5, m)

# Priors
a_mu_prior <- matrix(0, m)
a_v_i_prior <- diag(c(tau1^2), m)

# Initial value of Sigma
sigma_i <- solve(sigma_ols)

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

# Run SSVS
lambda <- ssvs(a = a, tau0 = tau0, tau1 = tau1,
               prob_prior = prob_prior)

# }

Run the code above in your browser using DataLab