Technical note: Rewritten September 4, 2026 against current statsmodels guidance. Pin Python, statsmodels, pandas, NumPy, and data versions.

ARIMA models autocorrelation in a univariate time series after differencing. The order (p,d,q) specifies autoregressive lags, differencing, and moving-average error terms. ARIMA is not automatically appropriate for every trend, seasonality, intervention, irregular interval, or changing process.

Define the forecasting task

Specify target, units, sampling frequency, forecast origin, horizon, update cadence, data availability, missing timestamps, interventions, and decision costs. Preserve chronological order. Aggregate or interpolate only with a documented meaning.

Build a baseline and split by time

Compare with naive, seasonal-naive, or another simple operational forecast. Use an initial training period followed by validation/test periods or rolling-origin evaluation. Never randomly shuffle a time series or fit scaling, imputation, transformations, and order selection using future observations.

from statsmodels.tsa.arima.model import ARIMA

train = y.loc[:"2024-12-31"]
test = y.loc["2025-01-01":]

model = ARIMA(train, order=(1, 1, 1), trend="t")
result = model.fit()
forecast = result.get_forecast(steps=len(test))
mean = forecast.predicted_mean
interval = forecast.conf_int(alpha=0.05)

The order above is illustrative, not recommended universally. Trend terms permitted by statsmodels depend on integration order and specification. Confirm frequency, index alignment, convergence, and output semantics.

Select and diagnose carefully

Use plots and domain knowledge with ACF/PACF and information criteria as candidate evidence, not mechanical truth. Unit-root tests have assumptions and limited power; differencing should reflect the model and data-generating process. Compare plausible orders on rolling validation and inspect convergence and parameter stability.

Residuals should be examined for remaining autocorrelation, changing variance, outliers, distributional problems, and structural breaks. A non-significant diagnostic does not prove independence. Prediction intervals are conditional on model assumptions and should be empirically checked for coverage across horizons.

Report useful metrics

Report horizon-specific MAE or RMSE and scale-free metrics where appropriate, together with baseline skill and interval coverage/width. MAPE is undefined or unstable near zero and asymmetric. Include operational costs, missing forecasts, and regime/subgroup behavior.

Handle seasonality and exogenous inputs

Use SARIMA for modeled seasonal structure and ARIMAX/SARIMAX only when future exogenous values are available or separately forecast. Avoid leakage from revised or late-published covariates. Refit and re-evaluate after process changes; retain fallback and monitor errors, coverage, data quality, and drift.

Compare sequence methods in LSTM time-series forecasting, detect unusual behavior through anomaly detection techniques, and explore cohorts via time-series clustering.