shrinkTVP | R Documentation |
shrinkTVP
samples from the joint posterior distribution of the parameters of a time-varying
parameter model with shrinkage, potentially including stochastic volatility (SV), and returns the MCMC draws.
shrinkTVP(
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,
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
|
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) and Cadonna et al. (2020). 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 |
|
lambda2 |
(optional) |
kappa2 |
(optional) |
a_xi |
(optional) |
a_tau |
(optional) |
c_xi |
(optional) |
c_tau |
(optional) |
lambda2_B |
(optional) |
kappa2_B |
(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>
plot.shrinkTVP
, plot.mcmc.tvp
## Example 1, learn everything
set.seed(123)
sim <- simTVP(theta = c(0.2, 0, 0), beta_mean = c(1.5, -0.3, 0))
data <- sim$data
res <- shrinkTVP(y ~ x1 + x2, data = data)
# summarize output
summary(res)
## Example 2, hierarchical Bayesian Lasso
res <- shrinkTVP(y ~ x1 + x2, data = data,
learn_a_xi = FALSE, learn_a_tau = FALSE,
a_xi = 1, a_tau = 1)
## Example 3, non-hierarchical Bayesian Lasso
res <- shrinkTVP(y ~ x1 + x2, data = data,
learn_a_xi = FALSE, learn_a_tau = FALSE,
a_xi = 1, a_tau = 1,
learn_kappa2 = FALSE, learn_lambda2 = FALSE)
## Example 4, adding stochastic volatility
res <- shrinkTVP(y ~ x1 + x2, data = data,
sv = TRUE)
## Example 4, changing some of the default hyperparameters
res <- shrinkTVP(y ~ x1 + x2, data = data,
hyperprior_param = list(beta_a_xi = 5,
alpha_a_xi = 10))
## Example 5, using the triple gamma prior
res <- shrinkTVP(y ~ x1 + x2, data = data,
mod_type = "triple")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.