shrinkDTVPVAR {shrinkTVPVAR}R Documentation

Markov Chain Monte Carlo (MCMC) for TVP-VAR-SV models under dynamic shrinkage priors

Description

shrinkDTVPVAR samples from the joint posterior distribution of the parameters of a TVP-VAR-SV model as described in Cadonna et al. (2020) and returns the MCMC draws. The prior on the VAR coefficients is a dynamic shrinkage prior, as described in Knaus and Frühwirth-Schnatter (2023). The model can be written as:

Y_t = c_t + \Phi_{1,t} Y_{t-1} + \Phi_{2,t} Y_{t-2} + \cdots + \Phi_{p,t} Y_{t-p} + \epsilon_t

where \epsilon_t \sim \mathcal{N}_m(0, \Sigma_t).

Usage

shrinkDTVPVAR(
  y,
  p = 1,
  mod_type = "double",
  const = TRUE,
  niter = 5000,
  nburn = round(niter/2),
  nthin = 1,
  display_progress = TRUE,
  TVP_params_beta = list(),
  TVP_params_sigma = list()
)

Arguments

y

matrix or data frame containing the time series data. The rows correspond to the time points and the columns to the variables.

p

positive integer indicating the number of lags in the VAR model. The default value is 1.

mod_type

character string that reads either "triple", "double" or "ridge". Determines whether the triple gamma, double gamma or ridge prior are used for theta_sr and beta_mean. The default is "double".

const

logical value indicating whether a constant should be included in the model. The default value is TRUE.

niter

positive integer, indicating the number of MCMC iterations to perform, including the burn-in. Has to be larger than or equal to nburn + 2. The default value is 5000.

nburn

non-negative integer, indicating the number of iterations discarded as burn-in. Has to be smaller than or equal to niter - 2. The default value is round(niter/2).

nthin

positive integer, indicating the degree of thinning to be performed. Every nthin draw is kept and returned. The default value is 1, implying that every draw is kept.

display_progress

logical value indicating whether the progress bar and other informative output should be displayed. The default value is TRUE.

TVP_params_beta

optional named list containing hyperparameter values for the TVP prior of the beta_mean matrix. Not all have to be supplied, with those missing being replaced by the default values. Any list elements that are misnamed will be ignored and a warning will be thrown. Can either be a list of depth 1, which results in all equations having the same hyperparameters, or a list of lists of length m, where each sub-list contains the hyperparameters for the respective equation. If sub-lists are provided, they can be unnamed, in which case the order of the elements is assumed to be the same as the order of the equations in the data. Alternatively, they can be named eq1, eq2, ..., eqm. The meaning of the hyperparameters is the same as in shrinkDTVP, as this function is used to sample the TVP coefficients. A key difference lies in how the adaptive MH arguments for theta and beta_mean are provided. In this function, the adaptive MH arguments are provided as vectors of length 4, where the elements control the MH steps in following order: a_xi, a_tau, c_xi, c_tau. E.g. if adaptive = c(FALSE, TRUE, TRUE, FALSE), then the MH step for a_xi and c_tau are non-adaptive, while the MH step for a_tau and c_xi are adaptive. Most hyperparameters to be provided are the same as in shrinkTVPVAR, however, the following additional ones are required for the dynamic shrinkage prior:

  • iid: logical. The default value is TRUE.

  • a_psi: numeric vector of length m*p if const is FALSE and m*p + 1 if const is TRUE. The default value is a vector filled with 0.5.

  • c_psi: numeric vector of length m*p if const is FALSE and m*p + 1 if const is TRUE. The default value is a vector filled with 0.5.

  • a_rho: positive, real number. The default value is 2.

  • b_rho:positive, real number between 0 and 1. The default value is 0.95.

  • alpha_rho: numeric vector of length m*p if const is FALSE and m*p + 1 if const is TRUE. The default value is a vector filled with 0.5.

  • beta_rho: numeric vector of length m*p if const is FALSE and m*p + 1 if const is TRUE. The default value is a vector filled with 3.

  • tuning_par_rho: positive, real number. The default value is 1.

  • adaptive_rho: logical. If TRUE, the MH step for rho is adaptive, otherwise it is not. The default value is TRUE.

  • target_rate_rho: positive, real number. The default value is 0.44.

  • batch_size_rho: positive integer. The default value is 50.

  • max_adapt_rho: positive, real number. The default value is 0.01.

TVP_params_sigma

optional named list containing hyperparameter values for the TVP prior of the Sigma matrix. The structure is the same as for TVP_params_beta. The default values are the same as for TVP_params_beta.

Details

The elements of the VAR coefficients \Phi_{i,t} are assumed to follow component-wise random walks.

For further details concerning the algorithms and the model please refer to the papers by Cadonna et al. (2020) and Knaus and Frühwirth-Schnatter (2023).

Value

A list of class "shrinkDTVPVAR" containing:

beta

an mcmc.tvp.var object with the VAR coefficient draws.

beta_mean

an mcmc.var object with the beta_mean draws.

theta_sr

an mcmc.var object with the theta_sr draws.

xi2

an mcmc.var object with the xi2 draws.

c_xi

an mcmc object with the c_xi draws.

kappa2

an mcmc.var object with the kappa2 draws.

kappa2_B

an mcmc object with the kappa2_B draws.

a_xi

an mcmc object with the a_xi draws.

tau2

an mcmc.var object with the tau2 draws.

c_tau

an mcmc object with the c_tau draws.

lambda2

an mcmc.var object with the lambda2 draws.

lambda2_B

an mcmc object with the lambda2_B draws.

a_tau

an mcmc object with the a_tau draws.

Sigma

an mcmc.tvp.var object with the covariance matrix draws.

psi

an mcmc.tvp.var object with the psi draws.

rho_p

an mcmc.var object with the rho draws.

pred_objs

a list with objects needed for prediction methods.

final_lambda

an mcmc.var with the values of lambda at time T of the dynamic shrinkage process. Used for predicting.

final_lambda_SIGMA

an array with the values of lambda of the variance-covariance matrix Sigma at time T of the dynamic shrinkage process. Used for predicting.

rho_p_SIGMA

an array with the rho_p values of the variance-covariance matrix Sigma. Used for predicting.

beta_consts

a list of mcmc.tvp objects with the intercept draws (if const is TRUE).

psi_consts

a list of mcmc.tvp objects with the psi draws (if const is TRUE).

data

a list with the original data used for estimation.

Author(s)

Peter Knaus peter.knaus@wu.ac.at

References

Cadonna, A., Frühwirth-Schnatter, S., & Knaus, P. (2020). Triple the Gamma—A Unifying Shrinkage Prior for Variance and Variable Selection in Sparse State Space and TVP Models. Econometrics, 8(2), 20.

Knaus, P., Bitto-Nemling, A., Cadonna, A., & Frühwirth-Schnatter, S. (2021). Shrinkage in the Time-Varying Parameter Model Framework Using the R Package shrinkTVP. Journal of Statistical Software, 100(13), 1–32.

Knaus, P., & Frühwirth-Schnatter, S. (2023). The Dynamic Triple Gamma Prior as a Shrinkage Process Prior for Time-Varying Parameter Models. arXiv preprint arXiv:2312.10487.

See Also

TV_heatmap, density_plotter, state_plotter

Examples

## Not run: 
set.seed(123)
sim <- simTVPVAR(p = 2)
data <- sim$data

res <- shrinkDTVPVAR(data, p = 2)

# Visualize the results
plot(res)
plot(res$theta_sr)

# Change prior to triple gamma
res2 <- shrinkDTVPVAR(data, p = 2, mod_type = "triple")

# Modify the hyperparameter setup
hyperparam <- list(learn_a_xi = FALSE, learn_c_xi = FALSE,
                  learn_a_tau = FALSE, learn_c_tau = FALSE,
                  a_xi = 0.5, c_xi = 0.5, a_tau = 0.5, c_tau = 0.5)

res3 <- shrinkDTVPVAR(data, p = 2, mod_type = "triple",
                    TVP_params_beta = hyperparam,
                    TVP_params_sigma = hyperparam)

## End(Not run)


[Package shrinkTVPVAR version 1.0.1 Index]