shrinkDTVP | R Documentation |
shrinkTVP
samples from the joint posterior distribution of the parameters of a time-varying
parameter model with dynamic triple gamma shrinkage, potentially including stochastic volatility (SV),
and returns the MCMC draws.
shrinkDTVP(
formula,
data,
mod_type = "double",
niter = 10000,
nburn = round(niter/2),
nthin = 1,
learn_a_xi = TRUE,
learn_a_tau = TRUE,
a_xi = 0.1,
a_tau = 0.1,
learn_c_xi = TRUE,
learn_c_tau = TRUE,
c_xi = 0.1,
c_tau = 0.1,
a_eq_c_xi = FALSE,
a_eq_c_tau = FALSE,
learn_kappa2_B = TRUE,
learn_lambda2_B = TRUE,
kappa2_B = 20,
lambda2_B = 20,
a_psi = 0.5,
c_psi = 0.5,
iid = FALSE,
shrink_inter = TRUE,
hyperprior_param,
display_progress = TRUE,
sv = FALSE,
sv_param,
MH_tuning,
starting_vals
)
formula |
object of class "formula": a symbolic representation of the model, as in the
function |
data |
optional data frame containing the response variable and the covariates. If not found in |
mod_type |
character string that reads either |
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 |
learn_a_xi |
logical value indicating whether to learn a_xi, the spike parameter of the state variances.
Ignored if |
learn_a_tau |
logical value indicating whether to learn a_tau, the spike parameter of the mean of the
initial values of the states. Ignored if |
a_xi |
positive, real number, indicating the (fixed) value for a_xi. Ignored if
|
a_tau |
positive, real number, indicating the (fixed) value for a_tau. Ignored if
|
learn_c_xi |
logical value indicating whether to learn c_xi, the tail parameter of the state variances.
Ignored if |
learn_c_tau |
logical value indicating whether to learn c_tau, the tail parameter of the mean of the
initial values of the states. Ignored if |
c_xi |
positive, real number, indicating the (fixed) value for c_xi. Ignored if
|
c_tau |
positive, real number, indicating the (fixed) value for c_tau. Ignored if
|
a_eq_c_xi |
logical value indicating whether to force |
a_eq_c_tau |
logical value indicating whether to force |
learn_kappa2_B |
logical value indicating whether to learn kappa2_B, the global level of shrinkage for
the state variances. The default value is |
learn_lambda2_B |
logical value indicating whether to learn the lambda2_B parameter,
the global level of shrinkage for the mean of the initial values of the states. The default value is |
kappa2_B |
positive, real number, indicating the (fixed) value for kappa2_B. Ignored if
|
lambda2_B |
positive, real number, indicating the (fixed) value for lambda2_B. Ignored if
|
a_psi |
positive, real number, or a vector of length equal to the number of covariates containing positive, real numbers. Indicates the value for a_psi, which is the pole parameter of the dynamic triple gamma. The default value is 0.5. |
c_psi |
positive, real number, or a vector of length equal to the number of covariates containing positive, real numbers. Indicates the value for c_psi, which is the tail parameter of the dynamic triple gamma. The default value is 0.5. |
iid |
logical value indicating whether the innovations are assumed to be independent and identically distributed.
If set to |
shrink_inter |
logical value indicating whether to dynamically shrink the intercept. Note that shrinkage is still applied
to the |
hyperprior_param |
optional named list containing hyperparameter values. 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. All hyperparameter values have to be positive, real numbers. The following hyperparameters can be supplied:
|
display_progress |
logical value indicating whether the progress bar and other informative output should be
displayed. The default value is |
sv |
logical value indicating whether to use stochastic volatility for the error of the observation
equation. For details please see |
sv_param |
optional named list containing hyperparameter values for the stochastic volatility
parameters. 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. Ignored if
|
MH_tuning |
optional named list containing values used to tune the MH steps for
|
starting_vals |
optional named list containing the values at which the MCMC algorithm will be initialized. In the
following
|
For details concerning the algorithms please refer to the papers by Bitto and Frühwirth-Schnatter (2019), Cadonna et al. (2020) and Knaus and Frühwirth-Schnatter (2023). For more details on the package and the usage of the functions, see Knaus et al. (2021).
The value returned is a list object of class shrinkTVP
containing
beta |
|
beta_mean |
|
theta_sr |
|
tau2 |
|
xi2 |
|
psi |
|
lambda_p |
|
kappa_p |
(optional) |
lambda2 |
(optional) |
kappa2 |
(optional) |
a_xi |
(optional) |
a_tau |
(optional) |
c_xi |
(optional) |
c_tau |
(optional) |
lambda2_B |
(optional) |
kappa2_B |
(optional) |
rho |
(optional) |
sigma2 |
|
C0 |
(optional) |
sv_mu |
(optional) |
sv_phi |
(optional) |
sv_sigma2 |
(optional) |
MH_diag |
(optional) named list containing statistics for assessing MH performance. Not returned if no MH steps are required or none of them are specified to be adaptive. |
internals |
|
priorvals |
|
model |
|
summaries |
|
To display the output, use plot
and summary
. The summary
method displays the specified prior values stored in
priorvals
and the posterior summaries stored in summaries
, while the plot
method calls coda
's plot.mcmc
or the plot.mcmc.tvp
method. Furthermore, all 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
Bitto, A., & Frühwirth-Schnatter, S. (2019). "Achieving shrinkage in a time-varying parameter model framework." Journal of Econometrics, 210(1), 75-97. <doi:10.1016/j.jeconom.2018.11.006>
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>
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. <doi:10.48550/arXiv.2312.10487>
plot.shrinkTVP
, plot.mcmc.tvp
set.seed(123)
sim <- simTVP(DTG = TRUE, theta = c(0, 1, 0), beta_mean = c(1, 1, 0), rho = 0.95, c_psi = 2)
data <- sim$data
## Example 1, match the true underlying process
res <- shrinkDTVP(y ~ x1 + x2, data = data, c_psi = 2)
# summarize output
summary(res)
## Example 2, dynamic horseshoe
res <- shrinkDTVP(y ~ x1 + x2, data = data)
## Example 3, modify hyperparameters
res <- shrinkDTVP(y ~ x1 + x2, data = data,
hyperprior_param = list(a_rho = 1,
alpha_rho = 0.5,
beta_rho = 0.5))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.