| dynamic_prior | R Documentation |
Builds the prior hyperparameters used by fit_dynamic_model(). Called with
no arguments it returns weakly informative defaults.
dynamic_prior(
var_shape = 0.01,
var_rate = 0.01,
df_min = 3,
df_mean_excess = 6,
mix_components = 2,
mix_concentration = 1,
mix_var_shape = 2.5,
mix_var_rate = 0.5,
sv_prior = NULL,
zi_open_a = 1,
zi_open_b = 1,
ar_rho_mean = 0,
ar_rho_sd = 1,
mu_mean = 0,
mu_sd = 1,
init_mean = 0,
init_var = 100
)
var_shape |
Shape of the inverse-gamma prior on the innovation
variance/scale. Default |
var_rate |
Rate of the inverse-gamma prior on the innovation
variance/scale. Default |
df_min |
Lower bound for the Student-t degrees of freedom. Default |
df_mean_excess |
Prior mean of |
mix_components |
Number of components in the scale-mixture innovation
structure. Default |
mix_concentration |
Symmetric Dirichlet concentration for the mixture
weights. Default |
mix_var_shape, mix_var_rate |
Shape and rate of the inverse-gamma prior
on the relative variance of each mixture component (used only when
|
sv_prior |
Optional stochvol prior specification for the
stochastic-volatility innovation structure. Default |
zi_open_a, zi_open_b |
Beta prior parameters for the gate-open
probability in zero-inflated models. Default |
ar_rho_mean, ar_rho_sd |
Mean and standard deviation of the Gaussian
prior on the AR(1) coefficient |
mu_mean, mu_sd |
Mean and standard deviation of the Gaussian prior on the
drift/intercept |
init_mean, init_var |
Mean and variance of the Gaussian prior on
the initial latent state, used under both random-walk and AR(1) dynamics.
Defaults |
The model places a GMRF latent process on the series z_t (a log-rate
for the Poisson family, a logit for the binomial family, and one
additive-log-ratio series per non-baseline category for the multinomial
family): either a first-order
random walk (latent_dynamics = "rw") or an AR(1) process
(latent_dynamics = "ar1"). The increments
\varepsilon_t = z_t - \mu - \rho\, z_{t-1} (with \rho = 1 for the
random walk and \mu = 0 unless a drift/intercept is included) are given
one of four innovation distributions, each governed by some of the priors
below.
Innovation variance (all structures). The baseline increment
variance \sigma^2 (or, for the "t"/"mixture" structures, the
overall scale) has an inverse-gamma prior
\sigma^2 \sim \mathrm{InvGamma}(\code{var\_shape}, \code{var\_rate}).
The default \mathrm{InvGamma}(0.01, 0.01) is weakly informative for
typical increment standard deviations, but it is not scale-free. For very
smooth or short series, with increment standard deviations of a few
hundredths, the results can be sensitive to this prior. In that regime, check the
sensitivity of the results to a smaller var_rate (which lets \sigma
become smaller) and expect slower mixing, because a nearly constant latent
path and a small \sigma are strongly dependent a posteriori.
In the multinomial family the same prior is applied independently to every
non-baseline category.
Mixture component variances (innovations = "mixture"). The
relative variances of the mixture components multiply the overall scale
and are given their own \mathrm{InvGamma}(\code{mix\_var\_shape},
\code{mix\_var\_rate}) prior (default \mathrm{InvGamma}(2.5, 0.5)).
They are kept moderately informative on purpose, as with a vague prior an
empty component would be drawn from an extremely heavy-tailed
distribution and the split between the overall scale and the component
variances is only weakly identified.
Student-t degrees of freedom (innovations = "t"). The degrees of
freedom are modelled as \nu = \code{df\_min} + E, where
E \sim \mathrm{Exp}(\mathrm{rate} = 1/\code{df\_mean\_excess}). Thus
\nu \ge \code{df\_min} and its prior mean is
\code{df\_min} + \code{df\_mean\_excess}. Large \nu approaches
the Gaussian case.
Scale mixture (innovations = "mixture"). The mixture uses
mix_components variance components, each with an
\mathrm{InvGamma}(\code{mix\_var\_shape}, \code{mix\_var\_rate})
prior (see above), and symmetric Dirichlet weights with concentration
mix_concentration.
Stochastic volatility (innovations = "sv"). The log-variance
h_t of the increments follows
h_t = \mu_h + \phi (h_{t-1} - \mu_h) + \sigma_h \eta_t, and its
priors are delegated to stochvol. Pass a prior specification
created with stochvol::specify_priors() via sv_prior, or leave it NULL
to use the stochvol defaults.
Zero inflation (zeros = "inflated"). The probability that the
observation "gate" is open (i.e. that a zero is an ordinary sampling zero
rather than a structural zero) has a
\mathrm{Beta}(\code{zi\_open\_a}, \code{zi\_open\_b}) prior. The
default Beta(1, 1) is uniform.
AR(1) coefficient (latent_dynamics = "ar1"). When the latent
state follows z_t = \mu + \rho\, z_{t-1} + \varepsilon_t, the
coefficient \rho is given a Gaussian prior
\rho \sim \mathrm{N}(\code{ar\_rho\_mean}, \code{ar\_rho\_sd}^2),
truncated to the stationary region \rho \in (-1, 1). AR(1) always
carries an intercept
(include_mu = TRUE). Under latent_dynamics = "rw" the coefficient is
fixed at \rho = 1 and this prior is unused.
Drift / intercept (include_mu = TRUE). A scalar \mu in the
state equation z_t = \mu + \rho\, z_{t-1} + \varepsilon_t: a
drift under the random walk (\rho = 1) and an intercept
under AR(1) (where it is always enabled). It is given a Gaussian prior
\mu \sim \mathrm{N}(\code{mu\_mean}, \code{mu\_sd}^2). With
include_mu = FALSE (random walk only), \mu = 0 and is not sampled.
Initial state. A proper, fixed
\mathrm{N}(\code{init\_mean}, \code{init\_var}) prior (default
N(0, 100)) anchors the otherwise-improper GMRF on the first latent
state, under both "rw" and "ar1" dynamics. With the diffuse default
the initial state is
effectively determined by the data.
An object of class "dynamic_prior": a named list of hyperparameters.
fit_dynamic_model()
# Defaults
dynamic_prior()
# An informative variance prior and heavier-tailed t innovations
dynamic_prior(var_shape = 2.5, var_rate = 0.5, df_min = 2, df_mean_excess = 3)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.