shrinkTVPVAR {shrinkTVPVAR} | R Documentation |
shrinkTVPVAR
samples from the joint posterior distribution of the parameters of a TVP-VAR-SV
model with shrinkage as described in Cadonna et al. (2020) and returns the MCMC draws.
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)
.
shrinkTVPVAR(
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()
)
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 |
const |
logical value indicating whether a constant should be included in the model. The default value is |
niter |
positive integer, indicating the number of MCMC iterations
to perform, including the burn-in. Has to be larger than or equal to |
nburn |
non-negative integer, indicating the number of iterations discarded
as burn-in. Has to be smaller than or equal to |
nthin |
positive integer, indicating the degree of thinning to be performed. Every |
display_progress |
logical value indicating whether the progress bar and other informative output should be
displayed. The default value is |
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
|
TVP_params_sigma |
optional named list containing hyperparameter values for the TVP prior of the Sigma matrix.
The structure is the same as for |
The elements of the VAR coefficients \Phi_{i,t}
are assumed to follow component-wise
random walk.
For further details concerning the algorithms and the model please refer to the paper by Cadonna et al. (2020).
The value returned is a shrinkTVPVAR
object containing:
beta |
an object of class |
beta_mean |
an object of class |
theta_sr |
an object of class |
xi2 |
an object of class |
c_xi |
an object of class |
kappa2 |
an object of class |
kappa2_B |
an object of class |
a_xi |
an object of class |
tau2 |
an object of class |
c_tau |
an object of class |
lambda2 |
an object of class |
lambda2_B |
an object of class |
a_tau |
an object of class |
Sigma |
an object of class |
pred_objs |
a list containing objects required for prediction methods to work. |
beta_consts |
a list of |
data |
a list containing the input data, as well as the synthetic "covariates" used for estimation. |
Note that only the values pertaining to the VAR coefficients are returned. The values for the variance-covariance matrix are not returned.
To display the output, use plot
on various elements of the list, as well as the TV_heatmap
,
density_plotter
and state_plotter
function. Many functions that can be applied to coda::mcmc
objects
(e.g. coda::acfplot
) can be applied to all output elements that are coda
compatible.
Peter Knaus peter.knaus@wu.ac.at
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. <doi:10.3390/econometrics8020020>
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. <doi:10.18637/jss.v100.i13>
TV_heatmap
density_plotter
state_plotter
set.seed(123)
sim <- simTVPVAR(p = 2)
data <- sim$data
res <- shrinkTVPVAR(data, p = 2)
# Visualize the results
plot(res)
plot(res$theta_sr)
# Change prior to triple gamma
res2 <- shrinkTVPVAR(data, p = 2, mod_type = "triple")
# Modify the hyperparameter setup
# Estimate under hierarchical horseshoe prior
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 <- shrinkTVPVAR(data, p = 2, mod_type = "triple",
TVP_params_beta = hyperparam,
TVP_params_sigma = hyperparam)
# Can also specify different hyperparameters for each equation
# gen_TVP_params() is a helper function and returns a
# list of lists (if for_each_eq = TRUE) where each sub-list
# contains the hyperparameters for the respective equation
hyperparam2 <- gen_TVP_params(m = 3, for_each_eq = TRUE)
hyperparam2[[1]]$learn_a_xi <- FALSE
hyperparam2[[1]]$a_xi <- 0.5
res4 <- shrinkTVPVAR(data, p = 2, mod_type = "triple",
TVP_params_beta = hyperparam2)
# Now, a_xi is only fixed in first equation
plot(res4$a_xi)