Time series analysis (ARIMA)

Time series analysis (ARIMA)

ARIMA models describe and forecast a time series from its own past values and past errors, using differencing to remove trends.

What it is

A time series is a sequence of measurements in time order, usually at equal intervals: hourly temperature, daily river flow, monthly electricity demand, a sensor signal sampled every second. Unlike ordinary regression data, consecutive observations are usually correlated, so standard methods that assume independent data can mislead.

ARIMA (autoregressive integrated moving average) is a widely used class of models that exploits this correlation. It predicts the next value from previous values and previous forecast errors, after differencing the series to remove trends. It answers: how does this series depend on its own past, and what values are likely next, with what uncertainty? ARIMA is used for forecasting in energy, hydrology, economics, process control and environmental monitoring, usually following the Box–Jenkins approach of identify, fit, check.

Fundamentals

Stationarity

A stationary series has a constant mean, constant variance and an autocorrelation structure that does not change over time. The AR and MA parts of ARIMA assume stationarity, so trends and changing variance must be removed first. Differencing replaces each value with its change from the previous one:

y′t = yt − yt−1

where yt is the value at time t and y′t the differenced value. One difference removes a linear trend; a second removes a quadratic trend. Variance that grows with the level of the series is often stabilized with a log transform first.

Autocorrelation

The autocorrelation function (ACF) at lag k is the correlation between yt and yt−k, the value k steps earlier. The partial autocorrelation function (PACF) at lag k is the same correlation after removing the influence of all shorter lags. Their patterns guide the choice of model.

The three components

An autoregressive model of order p, AR(p), predicts from past values:

yt = c + φ1yt−1 + … + φpyt−p + εt

Here c is a constant, φ1 to φp are autoregressive coefficients and εt is white noise: uncorrelated random shocks with zero mean and constant variance.

A moving-average model of order q, MA(q), predicts from past shocks:

yt = μ + εt + θ1εt−1 + … + θqεt−q

where μ is the series mean and θ1 to θq are moving-average coefficients. This is not the same as a smoothing moving average.

The “integrated” part, of order d, means the series is differenced d times before the AR and MA terms are fitted. ARIMA(p, d, q) therefore says: after d differences, the series follows a model with p autoregressive and q moving-average terms. For example, ARIMA(1, 1, 0) says that each period’s change depends on the previous period’s change plus a random shock, while ARIMA(0, 1, 0) is a random walk, in which the best forecast of the next value is simply the last observed value. Coefficients are usually estimated by maximum likelihood. Seasonal ARIMA, written ARIMA(p, d, q)(P, D, Q)s, adds equivalent terms at the seasonal lag s, for example s = 12 for monthly data with a yearly cycle.

Model ACF pattern PACF pattern
AR(p) Decays gradually Cuts off after lag p
MA(q) Cuts off after lag q Decays gradually
ARMA(p, q) Decays gradually Decays gradually

Basic operation

ARIMA models are fitted in software such as R (arima, or auto.arima in the forecast package) or Python (statsmodels ARIMA or SARIMAX). Automatic routines can choose the orders for you, but working through the steps yourself shows why a model was chosen. The Box–Jenkins workflow runs as follows.

  1. Collect and clean the data. Make sure observations are equally spaced, in consistent units, with gaps and obvious errors handled. Set aside the most recent part of the series as a test set.
  2. Plot the series. Look for trend, seasonality, variance that changes with level, outliers and sudden shifts.
  3. Transform and difference. Apply a log transform if variance grows with level, then difference until the series looks stationary. Formal tests such as the augmented Dickey–Fuller (ADF) or KPSS test help decide. In practice d is usually 0, 1 or 2.
  4. Identify candidate orders. Inspect the ACF and PACF of the stationary series and propose a few small values of p and q using the patterns in the table above.
  5. Fit and compare. Fit each candidate and compare them with an information criterion such as AIC or BIC; lower values indicate a better balance of fit and simplicity.
  6. Check the residuals. They should resemble white noise: no significant spikes in their ACF and a non-significant Ljung–Box test. Structure left in the residuals means the model is missing something.
  7. Forecast. The output is a set of predicted future values with prediction intervals that widen as the forecast horizon grows. Compare them with the held-out test data.

Good practice

  • Always plot the raw series before modeling; many problems are obvious by eye.
  • Do not over-difference. Extra differencing introduces artificial negative autocorrelation and inflates forecast variance.
  • Prefer simple models with low orders; complex ones fit noise and forecast worse.
  • Validate on later data held out from fitting, never on a random split, because time order matters.
  • Expect accuracy to fall with horizon; long-range ARIMA forecasts drift toward the mean or trend.
  • Watch for structural breaks such as a new instrument or changed procedure, and model or split around them.

Key terms

  • Stationarity — the property of a series whose mean, variance and autocorrelation do not change over time.
  • Lag — the number of time steps separating two observations.
  • Autocorrelation function — the correlation of a series with itself at each lag.
  • Differencing — replacing each value by its change from the previous value to remove trend.
  • White noise — uncorrelated random variation with zero mean and constant variance.
  • Forecast horizon — how many time steps ahead a prediction is made.
  • Prediction interval — the range expected to contain a future value with a stated probability.

Video coming soon

About five minutes on Time series analysis (ARIMA): how it works in detail, how the data is acquired, and how it is analyzed.

Shopping cart

0
image/svg+xml

No products in the cart.

Continue Shopping