Autocorrelation & Lags
P7.ts-foundations.03 · Audience: Guest, IT/ML learner, Language professional · Prerequisites: Trend, Seasonality & Decomposition
Where next?
Later in Time-Series Foundations
P7.ts-foundations.03 · Audience: Guest, IT/ML learner, Language professional · Prerequisites: Trend, Seasonality & Decomposition
Later in Time-Series Foundations
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.
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 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.
Off by default. The mentor always gets your file; this only decides whether your own copy stays here. Copies live in this browser only - they do not follow you to another device, and clearing site data removes them.
Now 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.
Loading exercise…
Loading exercise…
Loading exercise…
Loading exercise…
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.
Loading your notes...