stan_sarima: Fitting a Multiplicative Seasonal ARIMA model.

View source: R/stan_models.R

stan_sarimaR Documentation

Fitting a Multiplicative Seasonal ARIMA model.

Description

Fitting a SARIMA model in Stan.

Usage

stan_sarima(
  ts,
  order = c(1, 0, 0),
  seasonal = c(0, 0, 0),
  xreg = NULL,
  period = 0,
  chains = 4,
  iter = 2000,
  warmup = floor(iter/2),
  adapt.delta = 0.9,
  tree.depth = 10,
  prior_mu0 = NULL,
  prior_sigma0 = NULL,
  prior_ar = NULL,
  prior_ma = NULL,
  prior_sar = NULL,
  prior_sma = NULL,
  prior_breg = NULL,
  series.name = NULL,
  ...
)

Arguments

ts

a numeric or ts object with the univariate time series.

order

a three length vector with the specification of the non-seasonal part of the ARIMA model. The three components c(p, d, q) are the AR, the number of differences, and the MA orders respectively.

seasonal

a three length vector with the specification of the seasonal part of the ARIMA model. The three components c(P, D, Q) are the seasonal AR, the degree of seasonal differences, and the seasonal MA orders respectively.

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, period = frequency(ts).

chains

an integer of the number of Markov Chains chains to be run. By default, chains = 4.

iter

an integer of total iterations per chain including the warm-up. By default, iter = 2000.

warmup

a positive integer specifying number of warm-up (aka burn-in) iterations. This also specifies the number of iterations used for step-size adaptation, so warm-up samples should not be used for inference. The number of warmup iteration should not be larger than iter.By default, warmup = iter/2.

adapt.delta

an optional real value between 0 and 1, the thin of the jumps in a HMC method. By default, is 0.9.

tree.depth

an integer of the maximum depth of the trees evaluated during each iteration. By default, is 10.

prior_mu0

The prior distribution for the location parameter in an ARIMA model. By default, sets student(7,0,1) prior.

prior_sigma0

The prior distribution for the scale parameter in an ARIMA model. By default, declares a student(7,0,1) prior.

prior_ar

The prior distribution for the auto-regressive parameters in an ARIMA model. By default, sets a normal(0,0.5) priors.

prior_ma

The prior distribution for the moving average parameters in an ARIMA model. By default, sets a normal(0,0.5) priors.

prior_sar

The prior distribution for the seasonal auto-regressive parameters in a SARIMA model. By default, uses normal(0,0.5) priors.

prior_sma

The prior distribution for the seasonal moving average parameters in a SARIMA model. By default, uses normal(0,0.5) priors.

prior_breg

The prior distribution for the regression coefficient parameters in a ARIMAX model. By default, uses student(7,0,1) priors.

series.name

an optional string vector with the series names.

...

Further arguments passed to varstan function.

Details

The function returns a varstan object with the fitted model.

If xreg option is used, the model by default will cancel the seasonal differences adjusted (D = 0). If a value d > 0 is used, all the regressor variables in xreg will be difference as well.

The default priors used in Sarima model are:

  • ar ~ normal(0,0.5)

  • ma ~ normal(0,0.5)

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

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

  • sar ~ normal(0,0.5)

  • sma ~ normal(0,0.5)

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

Value

A varstan object with the fitted SARIMA model.

Author(s)

Asael Alonzo Matamoros

References

Box, G. E. P. and Jenkins, G.M. (1978). Time series analysis: Forecasting and control. San Francisco: Holden-Day. Biometrika, 60(2), 297-303. doi:10.1093/biomet/65.2.297.

Kennedy, P. (1992). Forecasting with dynamic regression models: Alan Pankratz, 1991. International Journal of Forecasting. 8(4), 647-648. url: https://EconPapers.repec.org/RePEc:eee:intfor:v:8:y:1992:i:4:p:647-648.

Hyndman, R. & Khandakar, Y. (2008). Automatic time series forecasting: the forecast package for R. Journal of Statistical Software. 26(3), 1-22.doi: 10.18637/jss.v027.i03

See Also

garch, and set_prior.

Examples


 # Declare a multiplicative seasonal ARIMA model for the birth data.
 sf1 = stan_sarima(birth,order = c(0,1,2),
                   seasonal = c(1,1,1),iter = 500,chains = 1)


 #Declare an Dynamic Harmonic Regression model for the birth data.
 sf2 = stan_sarima(birth,order = c(1,0,1),
                   xreg = fourier(birth,K = 2),iter = 500,chains = 1)



bayesforecast documentation built on June 8, 2025, 10:42 a.m.