fit_arima: Automatic ARIMA fit

View source: R/ts_arima.R

fit_arimaR Documentation

Automatic ARIMA fit

Description

Selects the ARIMA ⁠(p, d, q)⁠ order automatically and returns the fitted model – the role of forecast::auto.arima. This is the univariate auto-fit entry point used by ts_arima() (constructor orders left NULL or set to ⁠(0, 0, 0)⁠), and is exported for standalone reuse (e.g. by harbinger). Its canonical counterpart is the exported fit_arima() in Python pytspredit.

Usage

fit_arima(x, auto = "aicc", max_order = 12, cv_folds = 2, horizon = NULL)

Arguments

x

Numeric vector: the training series.

auto

Selector: "aicc" (default, compact AICc search approximating forecast::auto.arima) or "cv" (ARIMA++: ACF/PACF-driven candidates plus horizon-matched rolling-origin cross-validation).

max_order

Cap for the 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.

Value

A list with order (the selected c(p, d, q)), include_mean, and the fitted model (a stats::arima object).

Examples

x <- as.numeric(co2)[1:60]
sel <- fit_arima(x)
sel$order

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