ts_arima: ARIMA

View source: R/ts_arima.R

ts_arimaR Documentation

ARIMA

Description

Create a time series prediction object based on the AutoRegressive Integrated Moving Average (ARIMA) family.

Built on base R stats::arima. Orders can be given explicitly or selected automatically: auto = "aicc" (a compact AICc search) or auto = "cv" (ARIMA++).

Usage

ts_arima(
  p = NULL,
  d = NULL,
  q = NULL,
  auto = "aicc",
  max_order = 12,
  cv_folds = 2,
  horizon = NULL
)

Arguments

p

Optional integer autoregressive order (NULL or (0,0,0) -> automatic).

d

Optional integer differencing order (NULL or (0,0,0) -> automatic).

q

Optional integer moving-average order (NULL or (0,0,0) -> automatic).

auto

Automatic selector when orders are NULL: "aicc" (default) or "cv".

max_order

Cap for ACF/PACF-driven candidate lags (ARIMA++).

cv_folds

Number of rolling origins for the CV selection (ARIMA++).

horizon

CV horizon (ARIMA++); NULL -> the detected seasonal period.

Details

ARIMA models combine autoregressive (AR), differencing (I), and moving average (MA) components. When p, d, q are NULL or all 0 (⁠(0, 0, 0)⁠ is read as the auto-fit sentinel, so a pure white-noise model is not reachable), fit() selects the order automatically via the exported fit_arima(). auto = "cv" (ARIMA++) is a smarter selector that fixes two weaknesses of the classic auto.arima:

  1. the (p, q) candidates come from the significant ACF/PACF lags (Box-Jenkins identification) instead of a fixed cap of 5, so a seasonal spike (e.g. lag 12) enters the search;

  2. the order is chosen by rolling-origin cross-validation matched to the forecast horizon (out-of-sample sMAPE), not by the in-sample AICc proxy.

This is the canonical counterpart of the Python pytspredit TsArima(auto="cv") and is exported for reuse (e.g. by harbinger).

Value

A ts_arima object (S3), which inherits from ts_reg.

References

  • G. E. P. Box, G. M. Jenkins, G. C. Reinsel, and G. M. Ljung (2015). Time Series Analysis: Forecasting and Control. Wiley (ACF/PACF identification).

  • R. J. Hyndman and Y. Khandakar (2008). Automatic time series forecasting: The forecast package for R. Journal of Statistical Software, 27(3), 1-22. doi:10.18637/jss.v027.i03

  • L. J. Tashman (2000). Out-of-sample tests of forecasting accuracy. International Journal of Forecasting, 16(4), 437-450 (rolling-origin evaluation).

  • D. Kwiatkowski, P. C. B. Phillips, P. Schmidt, Y. Shin (1992). Testing the null hypothesis of stationarity. Journal of Econometrics, 54(1-3), 159-178 (KPSS).

Examples

# Example: rolling-origin evaluation with multi-step prediction
library(daltoolbox)
library(tspredit)
data(tsd)
ts <- ts_data(tsd$y, 1)
samp <- ts_sample(ts, test_size = 5)
model <- ts_arima(p = 5, d = 0, q = 0)
model <- daltoolbox::fit(model, x = samp$train)
prediction <- as.vector(predict(model, x = samp$test[1,], steps_ahead = 5))
ev_test <- daltoolbox::evaluate(model, as.vector(samp$test), prediction)
ev_test

tspredit documentation built on Nov. 26, 2026, 1:07 a.m.