Stationarity · time series

Also known as: stationary time series · differencing

On this page 7

Stationarity is the property of a time series whose statistical behavior does not change over time: its mean, variance and autocorrelation structure stay the same regardless of when the series is observed. In time series & forecasting, it is the core assumption behind classical models such as ARIMA, and checking it is one of the first steps in any forecasting workflow within artificial intelligence and statistics.

A stationary time series fluctuates around a stable level with a consistent spread, so patterns learned from the past remain valid in the future. Most real business and sensor data are not stationary, which is why analysts transform them, most often by differencing, before fitting a model.

Strict and weak stationarity

Two formal definitions exist. Strict stationarity requires the entire joint probability distribution of any set of observations to be unchanged when shifted in time. This is a demanding condition that is rarely testable in practice.

Weak stationarity, also called covariance or second-order stationarity, requires only three things: a constant mean, a constant and finite variance, and an autocovariance that depends only on the lag, not on the calendar position. Forecasting practice almost always means weak stationarity when it uses the word.

The table below compares the two definitions and what each one guarantees for modeling.

DefinitionConditionPractical relevance
Strict stationarityFull joint distribution invariant to time shiftsTheoretical; hard to verify
Weak stationarityConstant mean, variance and lag-based autocovarianceBasis of ARMA modeling
Trend stationarityStationary after removing a deterministic trendHandled by detrending
Difference stationarityStationary after differencing; has a unit rootHandled by the I in ARIMA
Definitions of stationarity

A Gaussian process that is weakly stationary is also strictly stationary, because its distribution is fully defined by mean and covariance. For heavy-tailed or nonlinear processes, the two notions can diverge.

Why forecasting models need stationarity

Stationarity matters because a model can only generalize from history if the process that generated the history still holds. When the mean drifts or variance grows, parameters estimated on old data describe a process that no longer exists.

Nonstationary inputs also produce spurious regression: two independent random walks regressed on each other often show a high R-squared and significant coefficients purely by chance. Autocorrelation estimates become unreliable, and prediction intervals are systematically too narrow.

Machine learning forecasters face the same issue in another form. Tree-based models such as gradient boosting cannot extrapolate beyond the target range seen in training, so a rising trend is flattened. Deep-learning forecasters often apply per-window normalization, such as reversible instance normalization, to remove level shifts before learning.

A related but distinct concept is ergodicity, which allows time averages from a single long series to stand in for averages across many hypothetical realizations. Stationarity alone does not guarantee it, yet most forecasting practice assumes both implicitly. In the ARIMA framework, the integration order d records how many differences were needed to reach stationarity, while the autoregressive and moving-average parts then model the remaining dependence. A random walk, for instance, is integrated of order one: its levels wander without bound, but its increments form white noise.

Testing a series for stationarity

Diagnosis combines visual inspection with formal tests. A time plot, a rolling mean and rolling standard deviation, and the autocorrelation function (ACF) come first; an ACF that decays very slowly is the classic sign of a unit root.

The formal tests differ in their null hypothesis, which is the most common source of misreading. The table summarizes the main options.

TestNull hypothesisNotes
Augmented Dickey-Fuller (ADF)Series has a unit rootLow power near the unit-root boundary
Phillips-Perron (PP)Series has a unit rootRobust to heteroskedastic errors
KPSSSeries is stationaryComplements ADF with the opposite null
Zivot-AndrewsUnit root without a breakAllows one structural break
Seasonal tests (OCSB, Canova-Hansen)Seasonal unit root or stable seasonalityGuide seasonal differencing
Common stationarity tests

A robust practice is to run ADF and KPSS together. If ADF rejects its null and KPSS does not, the series is likely stationary; if the results conflict, the series may be trend-stationary or near the boundary, and judgment is required.

Transformations that induce stationarity

Differencing replaces each value with its change from the previous period and removes a stochastic trend. One round of first differencing is usually enough; a second round is rarely justified. Seasonal differencing subtracts the value one season earlier, such as 12 months or 7 days.

Each transformation targets a specific kind of nonstationarity, as the following table shows.

ProblemTransformationSide effect
Stochastic trend (unit root)First differencingLoses one observation; adds noise
Deterministic trendRegress out a time trendAssumes the trend continues
Growing varianceLog or Box-Cox transformRequires positive values
Seasonal level shiftsSeasonal differencingLoses one full season
Structural breakSegment the series or add a dummyNeeds a known break date
Transformations and the problem each addresses

Forecasts made on transformed data must be inverted back to the original scale. For log transforms, the naive back-transform gives a median rather than a mean forecast, so a bias adjustment is often applied.

Common mistakes and limitations

  • Over-differencing: differencing a stationary series introduces a negative lag-one autocorrelation near -0.5 and inflates forecast variance.
  • Reading p-values backward: failing to reject the ADF null does not prove a unit root; it may reflect a short sample.
  • Ignoring variance changes: a stable mean with growing volatility is still nonstationary and calls for a variance transform or a GARCH-type model.
  • Treating seasonality as noise: deterministic seasonality is better handled with Fourier terms or calendar features than with repeated differencing.
  • Assuming global models do not care: large neural forecasters still benefit from scaling and detrending, especially on short or shifting series.

Stationarity is also a modeling convenience, not a law. Cointegrated series, for example, are individually nonstationary but share a stable long-run relation, and differencing them separately discards exactly the information worth modeling.

Put simply

A stationary series is one whose basic character stays the same. It moves up and down, but around the same average and by about the same amount. Daily temperature changes are close to this. Total sales of a fast-growing company are not.

Forecasting works best when the future behaves like the past. So analysts often look at changes instead of raw values. A rising staircase becomes a steady line of equal steps. That steady line is much easier to predict.

In practice

A retail analytics team forecasts weekly revenue for 300 stores over a 12-week horizon. The raw series show steady growth, larger swings in high-revenue stores and a strong year-end peak. An ADF test fails to reject the unit-root null, and KPSS rejects stationarity, so both tests point the same way.

The team applies a log transform to stabilize the variance, takes first differences to remove the trend and uses Fourier terms for the annual pattern. On the transformed data, both tests now indicate stationarity, and an ARIMA baseline and a gradient boosting model trained on lag features both improve. The boosting model’s MASE drops from 1.18 to 0.86, mainly because it no longer flattens the growth trend in stores that opened recently.