Learn R Programming

dsp (version 1.2.0)

dsp_fit: MCMC Sampler for Models with Dynamic Shrinkage Processes

Description

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

Usage

dsp_fit(
  y,
  model_spec,
  nsave = 1000,
  nburn = 1000,
  nskip = 4,
  computeDIC = TRUE,
  verbose = TRUE,
  ...
)

# S3 method for dsp print(x, ...)

Value

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 nsave MCMC samples for the parameters named in mcmc_params

DIC

Deviance Information Criterion

mcpar

named vector of supplied nsave, nburn, and nskip

model_spec

the object supplied for model_spec argument

Arguments

y

a numeric vector of the T x 1 vector of time series observations

model_spec

a list containing model specification generated from dsp_spec().

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 DIC and the effective number of parameters p_d

verbose

logical; should extra information on progress be printed to the console? Defaults to FALSE

...

currently not used

x

object of class dsp from dsp_fit()

Details

A brief summary of the settings used to fit the model including number of iterations, burn in, and thinning rates.

Examples

Run this code
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)

Run the code above in your browser using DataLab