The time scale of mean reversion
A spread that is high today tends to be lower later, but how quickly? The autocorrelation at lag k measures how much today's deviation from the mean still shows k days later: subtract the mean, then ρₖ=Σₜxₜxₜ₋ₖ / Σₜxₜ². For a mean-reverting series these numbers fall like e^(-k/τ), and τ is the time scale: after τ days about 37% of a deviation remains and after τln 2 days (the half-life) half of it. scipy.optimize.curve_fit(model, x, y, p0=..., bounds=...) finds the parameters of any model by least squares. You pass the model as a function model(x, *params), a starting guess p0 and bounds that keep the parameter positive, and it returns the best parameters and their covariance matrix pcov; the standard errors are the square roots of its diagonal.
On the 10-year minus 2-year Treasury spread (6,697 days since 2000) the fit gives τ≈1,006 days with a standard error of about 5, a half-life near 697 days. That number is misleading. Repeat the fit on thirteen separate windows of 500 days and the half-life runs from 33 to 124 days: the spread reverted much faster inside each period than the full sample suggests, because the full sample also contains the slow swings between regimes. A tiny standard error only says the curve fits the autocorrelations well, not that the autocorrelations are stable. Fit by window, look at how the estimate moves, and report the range, not one number.
- Autocorrelation shows memory: for mean reversion it decays like exp(-k / tau).
curve_fitreturns a curve and its uncertainty: give it a start and bounds, and read the standard error frompcov.- A small standard error is not stability: refit on rolling windows before you trust a half-life.
Lab · what's graded
- Sample autocorrelations15 pts
- The decay model5 pts
- Fitting the time scale25 pts
- The half-life5 pts
- Rolling half-lives25 pts
- The spread study25 pts