| dsp_fit | R Documentation |
Wrapper function for fitting models with Dynamic Shrinkage Processes (DSP), including:
Adaptive Bayesian Changepoint analysis and local Outlier (ABCO),
Bayesian Trend Filter for Gaussian Data
Time-varying Regression
Bayesian Trend Filter with B-spline for irregularly spaced or functional time-series.
Bayesian Smoothing for Count Data
Method for printing basic information about the MCMC sampling settings for the fitted model
dsp_fit(
y,
model_spec,
nsave = 1000,
nburn = 1000,
nskip = 4,
computeDIC = TRUE,
verbose = TRUE,
...
)
## S3 method for class 'dsp'
print(x, ...)
y |
a numeric vector of the |
model_spec |
a list containing model specification generated from |
nsave |
integer scalar (default = 1000); number of MCMC iterations to record |
nburn |
integer scalar (default = 1000); number of MCMC iterations to discard (burn-in) |
nskip |
integer scalar (default = 4); number of MCMC iterations to skip between saving iterations, i.e., save every (nskip + 1)th draw |
computeDIC |
logical; if TRUE (default), compute the deviance information criterion |
verbose |
logical; should extra information on progress be printed to the console? Defaults to FALSE |
... |
currently not used |
x |
object of class dsp from |
A brief summary of the settings used to fit the model including number of iterations, burn in, and thinning rates.
dsp_fit returns an object of class "dsp".
An object of class "dsp" is defined as a list containing at least the following components:
mcmc_output |
a list of the |
DIC |
Deviance Information Criterion |
mcpar |
named vector of supplied nsave, nburn, and nskip |
model_spec |
the object supplied for model_spec argument |
Shared parameters across wrappers include:
mu: Conditional mean.
ypred: Posterior predictive \tilde{y}_t.
evol_sigma_t2: Variance of the state variable.
obs_sigma_t2: Observation variance \sigma^2_{\epsilon} (family = "gaussian").
dhs_phi, dhs_mean: DHS hyperparameter draws (evol_error = "DHS").
Model-specific parameters include:
changepoint (Gaussian):
omega: D-th differenced posterior mean draws, \mu_t.
zeta: anomaly component (when useAnom = TRUE).
zeta_sigma_t2: anomaly variance (when useAnom = TRUE).
gamma: threshold parameter in the thresholded DHS log-volatility dynamics.
regression (Gaussian):
beta: time-varying regression coefficient draws.
bspline (Gaussian):
beta: B-spline basis coefficient draws.
smoothing (Negative Binomial):
r: overdispersion parameter draws.
The data y may contain NAs, which will be treated with a simple imputation scheme
via an additional Gibbs sampling step. In general, rescaling y to have unit standard
deviation is recommended to avoid numerical issues when family is "gaussian".
set.seed(200)
signal = c(rep(0, 50), rep(10, 50))
noise = rep(1, 100)
noise_var = rep(1, 100)
for (k in 2:100){
noise_var[k] = exp(0.9*log(noise_var[k-1]) + rnorm(1, 0, 0.5))
noise[k] = rnorm(1, 0, sqrt(noise_var[k])) }
y = signal + noise
model_spec = dsp_spec(family = "gaussian", model = "changepoint",
D = 1, useAnom = TRUE, obsSV = "SV")
mcmc_output = dsp_fit(y, model_spec = model_spec, nsave = 500, nburn = 500)
print(mcmc_output)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.