Interactive statistics
Module 8: Time series & forecasting
Progresscompleted 0 / 63

Autocorrelation: today looks like yesterday

In regression the observations are independent: one row knows nothing about its neighbour. In a series that is false — today's revenue resembles yesterday's, and this Sunday resembles the last one. Such a link of a series with itself is called autocorrelation, and it has two sides. The bad one: ordinary regression on such data understates its own error and produces an overconfident forecast. The good one: if today depends on yesterday, then the past of the series can predict its future — and every model ahead stands on that.

the seriesy(t) vs y(t−1)r = 0.67correlogram: correlation at every lag1714lag →

Each bar is the correlation of the series with itself shifted by k days. Inside the grey band the value is indistinguishable from zero.

Take the series and shift a copy of it by one day. You get pairs: the value yesterday and the value today. Each pair is a dot on the right panel, and the cyan segments on the left connect the days the pairs are made of. The number r under the panel is the ordinary correlation from the previous module, computed on those pairs.

What it means

The correlogram is a working diagnostic, not decoration. Slow decay says the series needs differencing; peaks at multiples of a lag name the seasonal period; everything inside the significance band means there is nothing to model.

After a model is fitted, the correlogram is plotted again — this time on the residuals. If structure remains in them, the model has not taken all of the pattern and is worth extending. Residuals that look like pure noise are the main sign that a model is sufficient.

Alongside the ACF one usually looks at the partial autocorrelation (PACF): it shows the link at lag k with the influence of the intermediate days removed. The pair ACF and PACF is the classical way to pick the orders p and q — which is what the ARIMA lesson is about.

Where it shows up

Autocorrelation is present in almost everything measured over time: temperature, server load, traffic jams, attendance. Today's value is usually closer to yesterday's than to the yearly average.

Autocorrelation is what makes «tomorrow will be like today» work — the simplest weather forecast, and one that is hard to beat one day ahead.

The opposite case is negative autocorrelation: a large value is systematically followed by a small one. Inventory after a delivery behaves that way, and so does output after an intense training session.

Definitions

Lag
a shift of the series back by a given number of steps: lag 1 is yesterday's value, lag 7 is the value a week ago.
Autocorrelationrk=corr(yt,ytk)r_k = corr(y_t, y_{t−k})
the correlation of a series with itself shifted by k steps.
Correlogram (ACF)
a plot of autocorrelation across all lags at once; its shape of decay identifies the type of series and the period of the cycle.
Significance band±1.96/√n
the boundaries within which an autocorrelation cannot be told apart from chance.

When the method lies (assumptions)

Autocorrelation measures a linear link — just like ordinary correlation. A nonlinear dependence on the past (a spike after a threshold, say) can give r near zero while the series is genuinely predictable.

The ±1.96/√n band is derived assuming there are no real correlations at all. Across many lags some bars will cross it by chance: these are the same multiple comparisons as in the module on hypotheses.

Deep dive: the math and the mechanism (optional)

Why you cannot simply add «yesterday's value» as a feature to a regression and forget about autocorrelation: the estimate of the lag coefficient is biased downwards in finite samples (bias of order 1/n), and if autocorrelation remains in the model's residuals, the estimates stop being consistent at all. Hence a separate class of models rather than the trick «let's add a lag as a feature».

Formally, a series whose autocorrelation is nonzero only at lag 1 is an MA(1), and a series with an exponentially decaying ACF is an AR(1). «Decays smoothly» versus «cuts off at lag q» is the language in which a correlogram hints at the structure of a model.

Next →
Breakdowns like this live in the channel

Data analytics in plain words: how to count metrics, how not to fool yourself in an A/B test, what gets asked in interviews and how this site gets built. The channel is in Russian.

Open the Telegram channel