Autoregressive Integrated Moving Average (ARIMA)
ARIMA (AutoRegressive Integrated Moving Average) is a statistical time-series model that forecasts a series using its own past values and past forecast errors. It is written ARIMA(p, d, q) and is a standard choice when demand shows patterns such as trend or autocorrelation that simple averages cannot capture.
The three parts
| Part | Symbol | Meaning |
|---|---|---|
| AutoRegressive (AR) | p | Number of past values of the series used as predictors |
| Integrated (I) | d | Number of times the series is differenced to make it stationary |
| Moving Average (MA) | q | Number of past forecast errors used as predictors |
Why differencing?
ARIMA assumes the series is stationary: its mean and variance do not drift over time. A series with trend is not stationary. Differencing replaces each value with its change from the previous value, which usually removes a trend.
Example: sales 100, 105, 112, 118, 127 become first differences 5, 7, 6, 9. The differences move around a steady level, so d = 1 is appropriate.
A tiny worked example
Suppose a fitted ARIMA(1,1,0) model for this series has the form: next difference = 4.2 + 0.4 × (latest difference). These parameter values are assumed for illustration; software would estimate them from data. The latest difference is 9.
Forecast difference = 4.2 + 0.4 × 9 = 7.8 Forecast level = 127 + 7.8 = 134.8
The model therefore forecasts about 134.8 for the next period. Note that the long-run average difference implied by the model is 4.2 ÷ (1 − 0.4) = 7.0, close to the observed average of 6.75, so the parameters are plausible for this data.
The Box-Jenkins steps
- Plot the data and look for trend, seasonality and outliers.
- Make it stationary: difference (and test with an Augmented Dickey-Fuller test). Use seasonal differencing if needed.
- Choose p and q using the autocorrelation (ACF) and partial autocorrelation (PACF) plots, or an automatic search.
- Estimate the parameters.
- Check the residuals: they should look like random noise with no autocorrelation.
- Compare models using AIC or BIC and out-of-sample error, then forecast.
In Python
from statsmodels.tsa.arima.model import ARIMA
model = ARIMA(y, order=(1, 1, 1)).fit()
forecast = model.forecast(steps=6)
Seasonality and outside drivers
For seasonal data use SARIMA, which adds seasonal terms (P, D, Q, m). To include external variables such as price or promotions, use ARIMAX.
When to use ARIMA, and when not to
- Good for: a single series with enough history (often 50 or more observations), stable structure and autocorrelation.
- Less suited: short histories, intermittent demand, new products, or when demand is driven by outside events. Consider Holt-Winters or regression instead.
- It is a “black box” compared with simple methods, so explain the result to business users with plots and error measures.
Common mistakes
- Over-differencing, which adds noise.
- Choosing the model only by in-sample fit instead of out-of-sample accuracy.
- Skipping residual checks.
- Forgetting to refit as new data comes in.
Key takeaways
- ARIMA(p, d, q) combines autoregression, differencing and moving-average error terms.
- Differencing makes the series stationary.
- Check residuals and compare models by error on held-out data.
- Use SARIMA for seasonality and ARIMAX for external drivers.
Put it into practice
Ready-made tools that apply this topic:
Frequently asked questions
What does ARIMA(p, d, q) mean?
p is the number of autoregressive terms, d is the number of times the series is differenced to make it stationary, and q is the number of moving-average (past error) terms.
What is a stationary time series?
A series whose mean, variance and autocorrelation do not change over time. Series with trend or seasonality are not stationary until they are differenced or adjusted.
How do I choose the p and q values?
Use autocorrelation and partial autocorrelation plots as a guide, or an automatic search, and compare candidate models with AIC or BIC and out-of-sample forecast error.
What is the difference between ARIMA and SARIMA?
SARIMA adds seasonal AR, differencing and MA terms so it can model repeating seasonal patterns as well as trend and autocorrelation.
How much data does ARIMA need?
As a rule of thumb at least 50 observations, and more for seasonal models. With short histories simpler methods are usually more reliable.
