# Stationarity, Differencing and Unit Roots

> A stationary series has stable statistical properties over time. Learn why prices are non stationary, how to test with ADF and KPSS and how to make data stationary.

Source: https://learn.tradelabsai.com/math/stationarity/  
Track: Math and Statistics · Level: Advanced · Updated: 2026-10-03  
Publisher: TradeLabs AI (https://tradelabsai.com). Education, not financial advice.  
Cite as: TradeLabs Learn, "Stationarity, Differencing and Unit Roots", https://learn.tradelabsai.com/math/stationarity/

A time series is stationary if its statistical properties, such as its mean, variance and autocorrelation, do not change over time. Stationarity matters because most statistical methods assume it: if the average and volatility of a series keep shifting, relationships estimated in the past may not hold in the future. Prices are almost never stationary; returns are much closer. Many trading strategies, especially mean reversion and pairs trading, depend on finding series that really are stationary.

## Types of stationarity

| Type | Definition |
|---|---|
| Strict stationarity | The full probability distribution does not change over time |
| Weak (covariance) stationarity | The mean, variance and autocovariances are constant over time |

In practice, "stationary" usually means weakly stationary.

## Stationary vs non stationary

| Series | Typically stationary? | Why |
|---|---|---|
| Stock prices | No | They trend and wander like a random walk |
| Returns | Approximately | Mean and variance are more stable, though volatility clusters |
| Spread between cointegrated assets | Yes (if truly cointegrated) | Pulled back to an equilibrium. See [Cointegration](https://learn.tradelabsai.com/math/cointegration/) |
| Interest rates | Debated | Very persistent; behaviour depends on the period |
| Volatility | Approximately, with mean reversion | Tends to return to long run levels |

## Unit roots

A random walk has a "unit root": shocks have a permanent effect, and the series does not return to a fixed mean. Many price series behave as if they have a unit root. Differencing them (taking changes) removes the unit root and produces a stationary series. See [White Noise and Random Walks](https://learn.tradelabsai.com/math/white-noise-and-random-walks/).

```
random walk: P_t = P_(t-1) + ε_t   (non stationary)
first difference: ΔP_t = P_t - P_(t-1) = ε_t   (stationary)
```

## Testing for stationarity

| Test | Null hypothesis | Interpretation |
|---|---|---|
| Augmented Dickey Fuller (ADF) | Series has a unit root (non stationary) | Rejecting the null suggests stationarity |
| Phillips Perron | Unit root | Similar to ADF, robust to some autocorrelation |
| KPSS | Series is stationary | Rejecting the null suggests non stationarity |

Using ADF and KPSS together gives a clearer picture, since they have opposite null hypotheses.

**Example: Testing a spread**
A trader builds a spread between two related stocks and runs an ADF test over three years of daily data. The test statistic is minus 3.9, below the 1% critical value of about minus 3.4, so the unit root null is rejected: the spread appears stationary over this period. The trader also estimates a half life of mean reversion of 12 days, which suits a pairs strategy. A year later, a new ADF test on recent data fails to reject the null, warning that the relationship may have broken. See [Pairs Trading](https://learn.tradelabsai.com/strategies/pairs-trading/).

## Half life of mean reversion

For a stationary, mean reverting series modelled as AR(1), the half life estimates how long a deviation takes to shrink by half:

```
half life = -ln(2) / ln(φ)
```

where φ is the AR(1) coefficient. For φ = 0.94 per day, the half life is about 11 days. See [Mean Reversion](https://learn.tradelabsai.com/strategies/mean-reversion/) and [ARIMA](https://learn.tradelabsai.com/math/arima/).

## Making data stationary

| Method | Use |
|---|---|
| Differencing | Turn prices into changes |
| Log returns | Turn prices into percentage like changes. See [Lognormal Distribution](https://learn.tradelabsai.com/math/lognormal-distribution/) |
| Detrending | Remove a fitted trend |
| Seasonal differencing | Remove calendar patterns |
| Volatility scaling | Divide returns by recent volatility to stabilise variance |

## Why stationarity matters for traders

- **Spurious regressions:** regressing non stationary series on each other produces false relationships. See [Regression Analysis](https://learn.tradelabsai.com/math/regression-analysis/).
- **Mean reversion strategies** only work on series that actually revert.
- **Machine learning features** built from non stationary data can fail out of sample. See [Feature Engineering](https://learn.tradelabsai.com/machine-learning/feature-engineering/).
- **Regime changes** break stationarity even in returns. See [Structural Breaks and Regime Changes](https://learn.tradelabsai.com/math/regime-changes/).

## Frequently asked questions

### What does stationary mean in time series?

That the series' statistical properties, such as its mean, variance and autocorrelation, stay constant over time.

### Are stock prices stationary?

No. Prices trend and wander, behaving like a random walk; returns are much closer to stationary.

### How do you test for stationarity?

With tests such as the Augmented Dickey Fuller (ADF) test, the Phillips Perron test and the KPSS test.

Next, learn how two non stationary series can stay together in [Cointegration](https://learn.tradelabsai.com/math/cointegration/).

## Continue learning

- Next lesson: [Cointegration](https://learn.tradelabsai.com/math/cointegration/)
- Previous lesson: [Autocorrelation and Partial Autocorrelation](https://learn.tradelabsai.com/math/autocorrelation/)
- Related: [Autocorrelation and Partial Autocorrelation](https://learn.tradelabsai.com/math/autocorrelation/): Autocorrelation measures how a series relates to its own past values. Learn the formula, the ACF, what positive and negative autocorrelation mean and why it matters.
- Related: [Cointegration](https://learn.tradelabsai.com/math/cointegration/): Cointegration means two non stationary series share a long run relationship. Learn the Engle Granger and Johansen tests, hedge ratios and pairs trading uses.
- Related: [White Noise and Random Walks](https://learn.tradelabsai.com/math/white-noise-and-random-walks/): A random walk is a path built from random steps; white noise is pure randomness. Learn how they model prices, the random walk hypothesis and the evidence against it.
- Related: [Time Series Basics](https://learn.tradelabsai.com/math/time-series-basics/): Market data is a time series: values ordered in time. Learn the components of a time series, why order matters, returns vs prices and the core tools for analysis.
- Related: [Mean Reversion](https://learn.tradelabsai.com/strategies/mean-reversion/): Mean reversion trades bet that prices stretched far from their average will come back. Learn the signals, z scores, examples and the risk of fading strong trends.
- Related: [Structural Breaks and Regime Changes](https://learn.tradelabsai.com/math/regime-changes/): Markets switch between regimes such as calm and turbulent, or trending and ranging. Learn how to detect regimes, the models used and how to adapt strategies.
