Autocorrelation & Lags
P7.ts-foundations.03 · Audience: guest, it-ml, language-pro · Prerequisites: Trend, Seasonality & Decomposition
Decomposition showed what a series is made of. This module measures how strongly the past predicts the present — the property that makes forecasting possible at all. The tool is autocorrelation: the correlation of a series with a time-shifted copy of itself. One number per shift, all plotted together, gives the ACF — the single most information-dense chart in time-series work, and one you will compute entirely by hand on a five-point series before any library touches it.
Take a daily series and make a scatter plot: horizontal axis yesterday's value, vertical axis today's. Each day contributes one point. This is a lag plot — the series plotted against a copy of itself shifted by one step (a lag of 1). If the points hug a rising diagonal, yesterday predicts today well. If they form a shapeless cloud, the series has no one-day memory, and no model will conjure any.
ⓘ Concept: Lag
Why it matters — Every forecasting method to come is a machine for exploiting lags: exponential smoothing weights recent lags, ARIMA regresses on them, and lag features are literally columns of shifted values. The lag plot is the honest first look at whether there is anything to exploit.
Lag plots exist for every shift: lag 7 pairs each day with the same weekday last week, lag 12 pairs each month with the same month last year. A tight lag-7 plot on daily data is weekly seasonality showing itself, one week apart at a time.
Ask the mentor about this module
Ask a question about this content. The mentor explains and grounds its answer in what you are studying; asking is recorded as a learning signal, not a grade.
🎓 Practice ladder
4 graded rungs · ~35 minNow measure memory yourself. Each rung is a three-panel workspace: instructions on the left, a code editor in the middle, output and test results on the right. Run checks the visible tests; Submit grades against hidden edge cases. The explorer rung reads a lag plot's printed correlations; the middle rungs build lag-k autocorrelation from raw means and variances and use it to find a hidden seasonal period; the senior rung differences a trending series and watches the ACF tell the truth at last.
Rung 1 — Read the lag plot (explorer)
Loading exercise…
Rung 2 — Build lag-k autocorrelation
Loading exercise…
Rung 3 — Find the season in the ACF
Loading exercise…
Rung 4 — ACF after differencing (senior)
Loading exercise…
Try it yourself
A scratch console for this page's ideas — ungraded, nothing you run here is recorded.
Scratch console
A scratch console with the scientific stack (pandas, numpy, scikit-learn). Runs on the server — no network, resource-limited and measured.
Output appears here.
Where next?
Later in Time-Series Foundations