Visual explainer
Time Series Forecasting (ARIMA)
Decompose temporal signals into trend, seasonality, and stationary noise, blending autoregressive memory with moving average shock corrections.
Standard machine learning assumes observations are Independent and Identically Distributed (i.i.d.): shuffling dataset rows preserves the underlying joint probability distribution. In time series analysis, this assumption completely fails. Temporal sequences possess strong autocorrelation: the value observed at week is physically and causally bound to values at week . Consider weekly sales figures . In chronological order, they reveal an unmistakable upward momentum and positive lag-1 autocorrelation (). Permuting those identical numbers into destroys the lag covariance structure, turning a predictable trend into meaningless random noise. In time series, temporal sequence is the signal.
Split the Signal
Real-world time series entangle multiple physical dynamics. Classical additive decomposition deconstructs raw observation into three orthogonal constituent components:
At week , an observed sales figure of decomposes into:
- Secular Trend (): The smooth, long-term multi-month growth trajectory.
- Seasonal Cycle (): Predictable periodic oscillations (such as weekend shopping surges or holiday demand spikes).
- Stochastic Irregular Residual (): The stationary, zero-mean leftover variation ().
Classical ARIMA models do not fit raw trending waves directly; they operate on the stationary irregular residual once deterministic trend and cyclical seasonality have been extracted.
Past Plus Error
The core engine of an ARMA(1, 1) model blends autoregressive inertia with moving average shock absorption:
Suppose the previous week's sales reached , and the model's previous forecast error (the shock) was . With estimated parameters and :
- The Autoregressive (AR) term captures persistence: .
- The Moving Average (MA) term damps recent surprise: .
- Summing both branches produces the calibrated point forecast: .
Over multi-step forecast horizons, compounding variance expands the confidence cone, providing honest probabilistic bounds on future uncertainty.
Three Small Knobs
Box-Jenkins forecasting requires weak stationarity: a constant mean , constant variance , and autocovariance depending exclusively on lag distance. Non-stationary series exhibit unit roots () that cause statistical forecasts to drift into infinite variance. The ARIMA framework resolves this through three coordinated levers:
- Differencing (): First-order differencing () transforms drifting non-stationary data into a stationary flat sequence of identical increments . Establishing stationarity () is the mandatory foundation.
- Autoregression (): Once stationary, the parameter specifies how many lagged historical observations () govern the forecast.
- Moving Average (): The parameter specifies how many lagged white noise error shocks () are factored into the estimate.
Beats Repeating Yesterday
Evaluating forecast performance against a naive persistence baseline () demonstrates the power of modeled error feedback:
- Naive persistence baseline: Simply assuming tomorrow equals today creates an inherent one-period lag. When trend accelerates or noise spikes occur, the naive forecast overshoots and oscillates, yielding a large Mean Absolute Error of across twelve weeks.
- ARIMA model: By combining autoregressive momentum with moving average error damping, the model anticipates trend slope and attenuates transient noise spikes. On the exact same twelve test weeks, ARIMA drops forecast error to —a reduction in forecast variance.
Small Orders First
Model complexity in time series is governed by Occam's razor and the Box-Jenkins principle of parsimony:
- Starting at Order 0 (naive mean), validation error sits at .
- Increasing to Order 1 (e.g., ARIMA) incorporates past values, reducing error to .
- Increasing to Order 2 (e.g., ARIMA) incorporates error damping, reaching the global error minimum of .
- Adding excess lag terms (Order 3 and beyond, such as ARIMA) introduces high-order polynomial roots that fit sample noise and cause AIC/BIC penalties to explode. Forecast error climbs back up to and . Stop adding parameters the moment held-out error stops falling.
Where It Breaks
Pure univariate ARIMA models operate under a fundamental vulnerability:
- Exogenous structural breaks: Univariate models possess no causal understanding of the external world. If an unexpected macroeconomic policy shift, competitor collapse, or viral event causes an immediate level shift at week 6 (jumping sales from 15 to 35), ARIMA assumes historical statistical stationarity.
- The lag void: The model treats the sudden jump as a transient moving average shock and crawls upward sluggishly, producing severe forecast deficits that lag real-world ground truth for six consecutive weeks.
- Operational safeguards: Production forecasting systems must incorporate external causal regressors (ARIMAX), automated changepoint detection algorithms that reset the stationarity window, and human-in-the-loop override protocols during known black swan disruptions.
The Quick Version
- Chronological sequence holds autocorrelation; shuffling destroyed time series structure.
- Additive decomposition breaks raw series into trend (8), seasonality (3), and residual noise (1).
- ARMA(1, 1) blends 70% of last value with 30% of last error to forecast 7.60.
- Differencing () turns drifting values [5, 7, 9] into stationary increments [2, 2].
- ARIMA drops test error from 4.10 (naive repeat) to 1.20 by actively damping shocks.
- Parsimony rule: stop adding lag terms at Order 2 where validation error hits its minimum.
- Univariate ARIMA is blind to exogenous shocks; use ARIMAX and changepoint detectors.