| ts_arima | R Documentation |
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++).
ts_arima(
p = NULL,
d = NULL,
q = NULL,
auto = "aicc",
max_order = 12,
cv_folds = 2,
horizon = NULL
)
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. |
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:
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;
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).
A ts_arima object (S3), which inherits from ts_reg.
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).
# 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
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.