bvs: Bayesian Variable Selection

Description Usage Arguments Details Value References Examples

View source: R/RcppExports.R

Description

bvs employs Bayesian variable selection as proposed by Korobilis (2013) to produce a vector of inclusion parameters for the coefficient matrix of a VAR model.

Usage

1
bvs(y, z, a, lambda, sigma_i, prob_prior, include = NULL)

Arguments

y

a K \times T matrix of the endogenous variables.

z

a KT \times M matrix of explanatory variables.

a

an M-dimensional vector of parameter draws. If time varying parameters are used, an M \times T coefficient matrix can be provided.

lambda

an M \times M inclusion matrix that should be updated.

sigma_i

the inverse variance-covariance matrix. If the variance-covariance matrix is time varying, a KT \times K matrix can be provided.

prob_prior

an M-dimensional vector of prior inclusion probabilities.

include

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

Details

The function employs Bayesian variable selection as proposed by Korobilis (2013) to produce a vector of inclusion parameters, which are the diagonal elements of the inclusion matrix Λ for the VAR model

y_t = Z_t Λ a_t + u_t,

where u_t \sim N(0, Σ_{t}). y_t is a K-dimensional vector of endogenous variables and Z_t = x_t^{\prime} \otimes I_K is a K \times M matrix of regressors with x_t as a vector of regressors.

Value

A matrix of inclusion parameters on its diagonal.

References

Korobilis, D. (2013). VAR forecasting using Bayesian variable selection. Journal of Applied Econometrics, 28(2), 204–230. https://doi.org/10.1002/jae.1271

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# Prepare data
data("e1")
data <- diff(log(e1))
temp <- gen_var(data, p = 2, deterministic = "const")
y <- temp$Y
x <- temp$Z
z <- kronecker(t(x), diag(1, nrow(y)))
t <- ncol(y)
m <- nrow(y) * nrow(x)

# Priors
a_mu_prior <- matrix(0, m)
a_v_i_prior <- diag(0.1, m)

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

# Initial value of Sigma
sigma <- tcrossprod(y) / t
sigma_i <- solve(sigma)

lambda <- diag(1, m)

z_bvs <- z %*% lambda

a <- post_normal_sur(y = y, z = z_bvs, sigma_i = sigma_i,
                     a_prior = a_mu_prior, v_i_prior = a_v_i_prior)

lambda <- bvs(y = y, z = z, a = a, lambda = lambda,
              sigma_i = sigma_i, prob_prior = prob_prior)

franzmohr/bvartools documentation built on Sept. 16, 2019, 5:11 p.m.