Free lesson · Time series
Stationarity: the assumption every test makes and every market breaks
Open interactive lessonPractice calculationsExplore labs
Start with the idea
Stationarity is a property of a stochastic process across time, not a statement that a chart looks flat. A weakly stationary process has stable first and second moments; one realised sample will still fluctuate.
Symbols, units & horizon
- xₜ: process value at observation time t
- μ: constant mean
- σ²: constant unconditional variance
- γ_k: covariance at lag k
- ∀t: for every time t
- E, Var, Cov: expectation, variance, covariance
- c: constant AR intercept, so μ=c/(1−φ)
- φ: AR coefficient, absolute value below 1
- εₜ: independent mean-zero innovation
- σ_ε²: innovation variance
- k: nonnegative lag in observation periods
When and why to use this
Use stationarity assumptions when fitting autoregressions and estimating dependence from repeated observations. Recheck them when a market changes its trading hours, policy regime or liquidity.
A series is (weakly) stationary if its mean, variance and autocovariances do not change over time. Almost every statistical tool — regression, correlation, t-tests, the CLT — quietly assumes this. Prices are not stationary: they wander. Returns are closer, but their variance shifts with regime.
Verify moments in a stable AR model
- For , take expectations under stationarity: , so .
- With independent innovation variance σ²ε, , hence for |φ|<1. Iterating covariance gives for nonnegative k.
- The moments depend on lag k, not calendar time t. These calculations verify the definition under the model assumptions; they are not a test that a market obeys it.
c=1, φ=.5, innovation variance 3 gives mean 2, variance 4, lag-one covariance 2.
This is why strategies decay. You estimated on a sample from one regime. The regime changed — rates rose, volatility doubled, the market-maker population turned over — and the conditional probability you measured no longer describes the process generating today's prices. The math did not fail; its precondition did.
You regress the S&P 500 price level on the number of Netflix subscribers, 2012–2021. The will be…
Both series trend upward over the decade, so a straight line through them fits extremely well. Neither causes the other. Regress the changes and the relationship vanishes. Trending (non-stationary) series make everything look related.
The standard check is the augmented Dickey–Fuller test: it asks whether the series has a unit root (a random-walk component). A small p-value rejects the unit-root null under the chosen lag and deterministic-term specification; it does not prove stable dynamics or a tradable edge. Estimated cointegration residuals require cointegration-specific critical values, not an ordinary ADF p-value.
Python implementation
Self-contained teaching example. Python 3.10+; dependencies and input conventions are shown in the code and notation. Run in your own Python environment.
def ar1_stationary_moments(mean_level, phi, innovation_variance, lag=0):
"""Stable AR(1): x_t-mu = phi*(x_prev-mu)+epsilon_t."""
if abs(phi) >= 1 or innovation_variance < 0 or lag < 0:
raise ValueError("Require |phi| < 1, variance >= 0, lag >= 0")
variance = innovation_variance/(1-phi**2)
return mean_level, variance, phi**lag*variance
print(ar1_stationary_moments(0, .8, 1, 1))Continue learning
Time Series Analysis — all lessons- Start with time order, lags and differences
- Before GARCH: mean, shocks and changing variance
- Stationarity: the assumption every test makes and every market breaks
- Autocorrelation: momentum, mean reversion, or coin flips
- GARCH: volatility clusters, and you can model the cluster
- Cointegration: a stationary relationship to test
- Forecast horizons, EWMA, and model diagnostics
- Markov chains: a two-state model you can calculate by hand
- Hidden Markov models: predict, observe, update
Quantitative finance and development glossary · Python resources and libraries · Research sources and limitations