Learn R Programming

bayesforecast (version 1.0.5)

ssm: A constructor for a Additive linear State space model.

Description

Constructor of the ets("Z","Z","Z") object for Bayesian estimation in Stan.

Usage

ssm(
  ts,
  trend = FALSE,
  damped = FALSE,
  seasonal = FALSE,
  xreg = NULL,
  period = 0,
  genT = FALSE,
  series.name = NULL
)

Value

The function returns a list with the data for running stan()

function of rstan package.

Arguments

ts

a numeric or ts object with the univariate time series.

trend

a bool value to specify a trend local level model. By default, trend = FALSE.

damped

a bool value to specify a damped trend local level model. By default, damped = FALSE. If trend = FALSE then damped = FALSE automatically.

seasonal

a bool value to specify a seasonal local level model. By default seasonal = FALSE.

xreg

Optionally, a numerical matrix of external regressors, which must have the same number of rows as ts. It should not be a data frame.

period

an integer specifying the periodicity of the time series by default the value frequency(ts) is used.

genT

a bool value to specify for a generalized t-student SSM model.

series.name

an optional string vector with the time series names.

Author

Asael Alonzo Matamoros.

Details

By default the ssm() function generates a local level ets("A","N","N"), or exponential smoothing model. If trend = TRUE, then the model transforms into a local trend, ets("A","A","N") or Holt model from the nforecast package. For damped trend models set damped = TRUE. When seasonal = TRUE, the model becomes a seasonal local level or ets("A","N","A")`` model from the \pkg{forecast} package. Finally, a Holt-Winters method or ets("A","A","A")`,is whenever both Trend and seasonal options are TRUE.

The genT = TRUE defines a t-student innovations SSM model. Check, Ardia (2010)) and Fonseca, et. al (2019) for more details.

The default priors used in a ssm( ) model are:

  • level ~ normal(0,0.5)

  • Trend ~ normal(0,0.5)

  • damped~ normal(0,0.5)

  • Seasonal ~ normal(0,0.5)

  • sigma0 ~ t-student(0,1,7)

  • level1 ~ normal(0,1)

  • trend1 ~ normal(0,1)

  • seasonal1 ~ normal(0,1)

  • dfv ~ gamma(2,0.1)

  • breg ~ t-student(0,2.5,6)

For changing the default prior use the function set_prior().

References

Fonseca, T. and Cequeira, V. and Migon, H. and Torres, C. (2019). The effects of degrees of freedom estimation in the Asymmetric GARCH model with Student-t Innovations. arXiv doi: arXiv: 1910.01398.

See Also

Sarima, auto.arima, set_prior, and garch.

Examples

Run this code
mod1 = ssm(ipc)

# Declaring a Holt model for the ipc data.
mod2 = ssm(ipc,trend = TRUE,damped = TRUE)

# Declaring an additive Holt-Winters model for the birth data
mod3 = ssm(birth,trend = TRUE,damped = TRUE,seasonal = TRUE)

Run the code above in your browser using DataLab