Plot a series against itself one step later, then two, then ten. Watch the cloud loosen as the lag grows.
A series remembers its past
A series where each value is 0.8 times the last plus noise, 200 values (seed 10100).
Each value is 0.8 times the one before plus fresh noise. Plot every value against the value one step later.
Predict first. Plot each value against the next one. What shape will the cloud have?
Describe this picture
Three panels. The first shows a series of 200 values (seed 10100) in which each value is 0.8 times the one before plus fresh noise of variance 1. Beside it (below it on a phone) is its lag plot: the points , each value against the value steps later, on a square from −5 to 5. The third panel dots the measured correlation of the lag plot for each lag, as a stem, over a dashed curve, , and a shaded band from to . Before the clip a question asks what the lag plot looks like at lag 1: a round blob, a slanted band, or a thin line. A tap picks one and starts the clip. In the clip lag 1 appears and holds, a slanted band with correlation 0.8124; then, about one second per step, the lag steps to 10, each change a short morph of the cloud. The cloud loosens to a round blob, and a dot is added below at each lag. Readouts give the lag, the measured correlation and . After the clip a slider sets the lag from 1 to 10.
Lag plots
Before the clip you guessed. At lag 1 the cloud is a slanted band: a high value tends to be followed by a high one. As the lag grows the band loosens, and by lag 10 it is nearly a round blob: the series has almost forgotten. The clip’s series measured 0.8124, 0.6236, 0.4729, 0.3520 and 0.2864 at lags 1 to 5, against 0.8, 0.64, 0.512, 0.410 and 0.328 in theory.
A time series is a sequence of values in time order: daily temperatures, monthly sales, a sensor read every second. I write the observed values , , and the random series behind them . Signal processing pages write the same thing , with the time; here is the number of values.
The correlation of the lag plot at lag measures how much the series remembers steps back. Taken lag by lag, it is the series’ autocorrelation function.
Trend, season and noise
Many series are three things added together: a slow trend, a season that repeats with a fixed period, such as 12 months, and noise:
A series is stationary if its behaviour does not drift over time: the mean stays the same, and so does the covariance between values a fixed number of steps apart. Trends and seasons break stationarity. They are usually removed first, as Smoothing and seasonality shows, and what is left is studied for its memory.
The autocorrelation function
For a stationary series with mean and variance , the autocovariance at lag is
the same for every , and the autocorrelation is . It is 1 at lag 0. The lag goes in square brackets; the log-likelihood of Maximum likelihood is a different use of the letter.
From data, use the sample mean and divide every lag by the same total:
White noise. A series of independent values with mean 0 has at every lag except 0. Its sample autocorrelations are not exactly 0; for about 95 % of lags they fall within . For 200 values that band is , the band in the picture.
Two extremes
A series with fading memory. The picture’s series is an AR(1) series, short for autoregressive of order 1:
where is white noise with variance and . Its autocorrelation decays geometrically, , and its variance is . Here is a coefficient; signal processing pages use the letter for a phase.
A series with no forgetting. With each step adds fresh noise to the last value: a random walk. Its variance after steps is , growing without limit, so it is not stationary, and its sample autocorrelation barely decays. Take its differences, , and you get the white noise back.
Trends that look related
Two series that both wander can look related when they are not.
Describe this picture
Two panels. The first, “two independent walks”, draws two independent random walks of 200 steps (seed 10101), one above the other, each scaled to its own band; their correlation, 0.4736, is a readout. The second, “correlations of 1000 pairs”, is a histogram of the correlations of 1000 such independent pairs on an axis from −1 to 1: spread widely, with much of it far from 0. The stretches beyond ±0.5 are then shaded, and a readout gives their share: 37.7 %. There is no control.
In the clip, the first pair of walks has a correlation of 0.4736, and 377 of the 1000 independent pairs, 37.7 %, land beyond ±0.5.
Watch out
Two series that both trend will often show a large correlation even when they have nothing to do with each other: each one’s values are correlated with their own past, so the usual rules for a correlation do not apply. Remove the trends, or take differences, before comparing series.
Cross-correlation
The same idea compares two series. If is a delayed copy of plus noise, correlate with for each lag . The correlation peaks at the lag equal to the delay. This is the cross-correlation , written with the delayed series first, as in Correlation of the signal processing course.
Worked example
1. A short series. The series has mean 3 and deviations , whose squares add to 12. The sums of lagged products are 5 at lag 1, at lag 2 and at lag 3, so
With only 8 values the white-noise band is , so none of these stands out: eight points cannot tell a pattern from noise. The plain correlation of the seven lag-1 pairs is , not , because it uses each set’s own mean and a different divisor; for long series the two agree closely.
2. The AR(1) series. With and , and . The autocorrelations are at lags 1 to 5. For 100 values the band is , and the theory drops below it at lag 8, where .
3. Many lags of white noise. Check 20 lags against a 95 % band: on average one falls outside, and the chance that at least one does is , the many-tests problem of p-values.
4. A delay. If is delayed by 3 samples plus noise, peaks at .
5. Trend and season. Monthly data with a rising trend and a yearly cycle have an autocorrelation that stays high at every lag and swings with period 12, peaking at lags 12, 24 and so on.
Try it yourself. For , . For 400 values the band is . A random walk of unit steps has variance 100 after 100 steps.
Where you’ll meet this
Is it noise? Checking that a signal, or the residuals of a fitted model, has no autocorrelation beyond the band is a standard check that nothing systematic is left. Linear regression assumes exactly that.
Delays and echoes. The delay between two microphones, two sensors or a sound and its echo is the lag of a cross-correlation peak.
Hidden periods. A peak in the autocorrelation at lag reveals a cycle of period : a machine’s vibration, a heartbeat, a weekly pattern in web traffic.
In signal processing · random processes
Signal processing treats noise as a random process with an autocorrelation in the same sense, writing it for a signal . Random processes and Correlation in the signal processing course use it to describe noise and find delays.
Where this leads · a positive definite matrix
Arrange the autocovariances in a matrix with in row and column . It is symmetric, constant along each diagonal, and positive definite, as a covariance matrix is unless some mix of the values has no spread: for AR(1) with the autocorrelation matrix has determinant . Positive definite matrices in the linear algebra course explain why.
Reference card
| Quantity | Formula | Notes |
|---|---|---|
| Decomposition | trend + season + noise | remove trend and season first |
| Stationary | mean and lagged covariances do not drift | |
| Autocovariance | ||
| Autocorrelation | 1 at lag 0 | |
| Sample version | , divide every lag by | |
| White noise band | about 95 % of lags inside | |
| AR(1) | , | fading memory |
| Random walk | variance | not stationary; difference it |
| Cross-correlation | peaks at the delay | delayed series first |