Skip to main content

ARIMA Models

AutoRegressive Integrated Moving Average - models dependencies between observations.

ModelDescription
ARIMAClassic ARIMA with manual parameter specification
AutoARIMAAutomatic ARIMA with (p,d,q) selection
ARIMAXARIMA with exogenous variables
Showing 3 of 3

ARIMA

Classic ARIMA model with manual parameter specification.

Parameters

ParameterTypeRequiredDescription
pINTEGERYesAR (autoregressive) order
dINTEGERYesDifferencing order
qINTEGERYesMA (moving average) order
seasonal_periodINTEGERNoFor seasonal ARIMA
PINTEGERNoSeasonal AR order
DINTEGERNoSeasonal differencing
QINTEGERNoSeasonal MA order

Example

-- Non-seasonal ARIMA(1,1,1)
SELECT * FROM ts_forecast_by(
'sales_data', NULL, date, sales,
'ARIMA', 28, '1d',
MAP{'p': '1', 'd': '1', 'q': '1'}
);

-- Seasonal ARIMA(1,1,1)(1,1,1)[7]
SELECT * FROM ts_forecast_by(
'weekly_data', NULL, date, value,
'ARIMA', 28, '1d',
MAP{'p': '1', 'd': '1', 'q': '1', 'P': '1', 'D': '1', 'Q': '1', 'seasonal_period': '7'}
);

Best for: Complex patterns when you know the appropriate order.


AutoARIMA

Automatic ARIMA with (p,d,q) parameter selection using information criteria.

Parameters

ParameterTypeDefaultDescription
seasonal_periodINTEGER-Seasonal period (detect with ts_detect_periods_by first)
max_pINTEGER5Maximum AR order
max_dINTEGER2Maximum differencing order
max_qINTEGER5Maximum MA order

Example

SELECT * FROM ts_forecast_by(
'sales_data', NULL, date, sales,
'AutoARIMA', 28, '1d',
MAP{'seasonal_period': '7'}
);

Best for: Complex patterns, long-term forecasts, automatic tuning.

Seasonality Not Auto-Detected

Seasonality is NOT auto-detected. You must detect the period first with ts_detect_periods_by and pass it explicitly via seasonal_period.


Parameter Selection Guide

Scenariopdq
Stationary data1-201-2
Trending data1-211-2
Strong trend1-221-2
Random walk010

When to Use ARIMA vs AutoARIMA

ScenarioRecommended
Known order from domain expertiseARIMA
Exploratory analysisAutoARIMA
Production pipelineAutoARIMA
Performance-criticalARIMA (faster)
Many time seriesAutoARIMA
External predictorsARIMAX

ARIMAX

ARIMA with exogenous (external) variables. Incorporates external predictors like temperature, promotions, or economic indicators.

Parameters

ParameterTypeDefaultDescription
seasonal_periodINTEGER-Seasonal period (detect with ts_detect_periods_by first)
max_pINTEGER5Maximum AR order
max_dINTEGER2Maximum differencing order
max_qINTEGER5Maximum MA order

Example

-- Create future exogenous values
CREATE TABLE future_exog AS
SELECT * FROM (VALUES
('2024-01-08'::DATE, 22.0, 1),
('2024-01-09'::DATE, 20.0, 0),
('2024-01-10'::DATE, 21.0, 1)
) AS t(date, temperature, promotion);

-- Forecast with exogenous variables
SELECT * FROM ts_forecast_exog_by(
'sales_data', NULL, date, sales,
['temperature', 'promotion'],
'future_exog', date, ['temperature', 'promotion'],
'ARIMAX', 3,
MAP{}, '1d'
);

Best for: Complex patterns with external drivers, weather-adjusted demand, promotion planning.

See Exogenous Variables for detailed usage

🍪 Cookie Settings