btf_nb | R Documentation |
Run the MCMC for Bayesian trend filtering with a penalty on first (D = 1) or second (D = 2) differences of the log conditional expectation of a Negative Binomial distribution. The penalty is determined by the prior on the evolution errors, currently only the following options are available:
the dynamic horseshoe prior ('DHS');
the static horseshoe prior ('HS');
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_nb(
y,
evol_error = "DHS",
D = 2,
nsave = 1000,
nburn = 1000,
nskip = 4,
mcmc_params = list("mu", "yhat", "evol_sigma_t2", "r", "dhs_phi", "dhs_mean"),
r_init = NULL,
r_sample = TRUE,
step = 1,
evol0_sample = FALSE,
evol0_sd = 10,
sigma_e = 1/sqrt(Nt),
chol0 = NULL,
computeDIC = TRUE,
offset = 0,
verbose = TRUE,
seed = NULL
)
y |
the length |
evol_error |
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) |
D |
degree of differencing (D = 0, D = 1, or D = 2) |
nsave |
number of MCMC iterations to record |
nburn |
number of MCMC iterations to discard (burnin) |
nskip |
number of MCMC iterations to skip between saving iterations, i.e., save every (nskip + 1)th draw |
mcmc_params |
character list of parameters for which we store the MCMC output; must be one or more of:
Defaults to everything. |
r_init |
numeric; initial value (defaults to 5) of MCMC sampling for
overdispersion parameter; must be an integer if r_sample is 'int_mh' or
|
r_sample |
logical; If |
step |
numeric (defaults to 1); step length of proposal distribution for
Metropolis-Hasting sampling of overdispersion parameter; ignored if r_sample is |
evol0_sample |
logical; if |
evol0_sd |
numeric; initial value (defaults to 10) or the fixed prior standard deviation
for the initial |
sigma_e |
numeric; scale value (defaults to |
chol0 |
logical; If anything except |
computeDIC |
logical; if TRUE, compute the deviance information criterion |
offset |
length |
verbose |
logical; If TRUE (the default), time remaining is printed to console |
seed |
optional seed for random number generation for reproducible results |
A named list with the following. One named element for each of the parameters specified in mcmc_params
containing
the nsave
posterior draws as a vector for scalar parameters and matrix for multivariate parameters.
An element named loglike
containing a vector of the nsave
evaluations of the log
likelihood of the data y
with a Negative Binomial distribution defined by the current iteration conditional expectation + offset and overdispersion.
If computeDIC
is TRUE
, a named element for the computed value of DIC and effective parameters p_d for the data y
with a Negative Binomial distribution defined by the posterior mean of the conditional expectation + offset and posterior
mean overdispersion.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.