Run the MCMC for Bayesian trend filtering with a penalty on zeroth (D = 0), first (D = 1), or second (D = 2) differences of the conditional expectation. The penalty is determined by the prior on the evolution errors, which include:
the dynamic horseshoe prior ('DHS');
the static horseshoe prior ('HS');
the Bayesian lasso ('BL');
the normal stochastic volatility model ('SV');
the normal-inverse-gamma prior ('NIG').
In each case, the evolution error is a scale mixture of Gaussians. Sampling is accomplished with a (parameter-expanded) Gibbs sampler, mostly relying on a dynamic linear model representation.
btf(
y,
evol_error = "DHS",
D = 2,
obsSV = "const",
nsave = 1000,
nburn = 1000,
nskip = 4,
mcmc_params = list("mu", "yhat", "evol_sigma_t2", "obs_sigma_t2", "dhs_phi",
"dhs_mean", "h", "h_smooth"),
computeDIC = TRUE,
verbose = TRUE,
D_asv = 1,
evol_error_asv = "HS",
nugget_asv = TRUE
)
A named list of the nsave
MCMC samples for the parameters named in mcmc_params
the T x 1
vector of time series observations
the evolution error distribution; must be one of 'DHS' (dynamic horseshoe prior; the default), 'HS' (horseshoe prior), 'BL' (Bayesian lasso), or 'NIG' (normal-inverse-gamma prior)
degree of differencing (D = 0, D = 1, or D = 2)
Options for modeling the error variance. It must be one of the following:
const: Constant error variance for all time points.
SV: Stochastic Volatility model.
ASV: Adaptive Stochastic Volatility model.
for the observation error variance
number of MCMC iterations to record
number of MCMC iterations to discard (burnin)
number of MCMC iterations to skip between saving iterations, i.e., save every (nskip + 1)th draw
named list of parameters for which we store the MCMC output; must be one or more of:
"mu" (conditional mean)
"yhat" (posterior predictive distribution)
"evol_sigma_t2" (evolution error variance)
"obs_sigma_t2" (observation error variance)
"dhs_phi" (DHS AR(1) coefficient)
"dhs_mean" (DHS AR(1) unconditional mean)
"h" (log variances or log of "obs_sigma_t2"
. Only used when obsSV = "ASV"
)
"h_smooth" (smooth estimate of log variances. Only used when obsSV = "ASV"
and nugget_asv = TRUE
)
logical; if TRUE, compute the deviance information criterion DIC
and the effective number of parameters p_d
logical; should R report extra information on progress?
integer; degree of differencing (0, 1, or 2) for the ASV model. Only used when obsSV = "ASV"
.
character; evolution error distribution for the ASV model. Must be one of the five options used in evol_error
. Only used when obsSV = "ASV"
.
logical; if TRUE
, fits the nugget variant of the ASV model. Only used when obsSV = "ASV"
.