TL;DR
The autocorrelation function of a stationary process says how strongly its value now is tied to its value a fixed number of steps later. At lag it is the correlation between and : a number from to that starts at for lag and fades as the gap grows. A slow fade means long memory; a fast fade means the process forgets quickly.
Where you'll see it: in checking whether the leftover errors of a forecasting model are really random, in estimating how many independent samples a Markov chain Monte Carlo run has produced, and in the Fluctuation-Dissipation Theorem of physics.
This lesson explains a statistical quantity. It is not advice about any particular data set or decision.
Intuition
Correlation with your own past
Take the daily high temperature in a city. Today's value tells you something about tomorrow, because weather persists. Yesterday tells you more about today than last week does, and last month tells you almost nothing. The autocorrelation function puts a number on that fading relevance.
You already know how correlation works for two different quantities. Pair up the values, measure how they move together with Covariance, and scale the result to lie between and . Autocorrelation does the same thing to one series against a shifted copy of itself. Pair each value with the value steps later. The shift is called the lag.
If a series is , the lag-1 pairs are , , and so on. The lag-2 pairs skip one step: , . Lag 0 pairs every value with itself, so the correlation there is always 1.
A picture of the memory
The result is usually drawn as a bar or dot chart against the lag, called a correlogram. Its shape is a fingerprint of the process. The plot below compares two autoregressive processes, each one a fraction of its previous value plus fresh noise. The dots show the correlogram of the first at whole-number lags.
- φ = 0.5
- φ = 0.9
Both curves start at 1 and fall off, because a value is most like its immediate neighbours. The curve with the larger holds on longer. That single curve is what this lesson is about.
The math
Definition
For a weakly stationary process with mean and variance , the autocovariance at lag is
and the autocorrelation function (ACF) is
Here is a time index, and is a whole number of steps. The notation is the expected value. Because the process is stationary, the right-hand side depends only on the lag and not on . That is why one curve can describe the whole series.
Three facts follow from the definition:
- , because a value is perfectly correlated with itself.
- . Looking backwards by gives the same pair of values, so the curve is symmetric.
- , since is the correlation between two random variables.
Estimating it from data
We never know or exactly. Given observations with sample mean , the standard estimate is
The numerator has products, because only pairs exist at lag . The denominator uses all squared deviations. Some texts divide the numerator by (and the denominator by ) instead; the numbers then differ slightly, and the convention above is the one most software uses.
Autoregressive example
Take the AR(1) model with and white noise of variance (see ARMA Model and White Noise). Its stationary variance is , from the Stationary Process lesson. Its autocorrelation has a clean form, and it is worth deriving once.
Repeat the recursion times:
Every noise term in the sum happens after time , so each one is uncorrelated with . Only the first term carries a link back to . Therefore
The memory decays geometrically, the same pattern as the Geometric Series of powers of . A negative makes the correlogram alternate in sign, but is positive, so the sign of is always positive.
Integrated autocorrelation time
Summing the correlogram gives one number for how much memory a series has:
This is the integrated autocorrelation time. Roughly, correlated observations are worth about independent ones. For the AR(1) model the sum is geometric, , so
This is the quantity behind the effective sample size in Markov Chain Monte Carlo and Metropolis Algorithm samplers.
Worked examples
Take the eight values , so .
- The sample mean is , because four values are and four are .
- The denominator is .
- At lag 1 there are pairs. Each pair is or , so each product is . The numerator is , and .
- At lag 2 there are pairs. Each pair matches in sign, so each product is . The numerator is , and .
- At lag 3 there are pairs, each with product , so .
Interpretation. The series is strongly anti-correlated at odd lags and strongly correlated at even lags. Its memory lives in the alternation, so the correlogram flips sign with each step while its size fades slowly.
For this model , and .
- Lag 1: .
- Lag 2: .
- Lag 5: .
- Lag 10: .
- Half-life: solve , which gives . The correlation halves after about three steps.
- Integrated time: .
Interpretation. A value still has about 64 percent of its link to the present after two steps, and only about 11 percent after ten. Nine correlated observations are worth about one independent one.
Suppose a Markov chain Monte Carlo run produces draws. Assume, for illustration, that the draws behave like an AR(1) process with . In practice is estimated from the sample itself, but the arithmetic is the same.
- Integrated time: .
- Effective sample size: .
- To get the accuracy of 10,000 independent draws, you would need about steps.
Interpretation. The average of these draws has the precision of about 526 independent ones. Checking the autocorrelation before trusting an average is therefore part of the job, not a formality.
Tradeoffs and failure modes
The ACF is a diagnostic. It answers well when its assumptions hold and misleads when they do not.
| Situation | What goes wrong | Better choice |
|---|---|---|
| Series with a trend or seasonal cycle | The ACF stays large across many lags, even between unrelated series, because the shared trend does the work | Remove the trend or seasonality, or difference the series, then read the ACF |
| Random walk | The process is not stationary, and its sample ACF stays near 1 for many lags | Difference the series (Random Walk) and examine the differences |
| Short record | Sample values at large lags are noisy and unreliable | Use fewer lags, or collect more data |
| Nonlinear dependence | Zero autocorrelation does not mean independence. Values can be uncorrelated while their squares are strongly linked | Examine the ACF of absolute or squared values as well |
| Many lags checked at once | With 20 lags, about one spike outside the band is expected by chance | Judge the overall pattern, not a single spike |
For white noise the sample ACF at each lag has a standard error of about . A common rule of thumb draws bands at . Spikes outside those bands suggest real memory. Spikes inside them are compatible with no memory at all.
The main trap is reading the first lag alone. Two series can have the same and very different memories beyond that. Look at the full curve, and remember that the partial autocorrelation, which removes the effect of the intermediate lags, is a separate tool used for choosing model orders.
History
Autoregressive models were first used for time series by George Udny Yule in the 1920s, to describe cycles such as sunspot counts. Work in the early 1930s by Norbert Wiener and, in 1934, by Aleksandr Khinchin tied the autocorrelation function to the spectrum of a stationary process; this is the spectral view in the Wiener–Khinchin theorem.
The correlogram became a working tool later. In the 1960s and 1970s George Box and Gwilym Jenkins showed how to choose a model by reading the ACF and partial ACF, then fit and check it. Their 1970 book made the method standard in forecasting and economics. The ACF caught on because it turns a single record into a picture of memory that anyone can read.
Recap
The autocorrelation function is the correlation between a stationary process and itself shifted by steps. It starts at 1, is symmetric, and stays between and . For an AR(1) process it decays as , and summing it gives the integrated autocorrelation time , which sets how many independent samples a correlated series is worth. The correlogram is the first diagnostic for memory, and it is the tool behind effective sample size in Markov Chain Monte Carlo and the response functions in Linear Response Theory.
Check yourself
QuestionWhat is , and why must equal ?Show answer
, because a value is perfectly correlated with itself. The symmetry comes from the definition: and describe the same pair of values, one shifted forwards and one backwards. Stationarity makes both depend only on the gap .
QuestionAn AR(1) process has . What is , and why is its sign positive?Show answer
. Two steps is an even number, so the minus sign from is squared away. The correlogram of this process alternates sign at each lag, but at even lags the sign is positive.
QuestionA series has a strong upward trend. Its sample ACF is about 0.9 at lags 1 through 20. Why does this not show that the series has long memory in its dynamics?Show answer
A trend makes every value resemble every other value, because they all lie on the same rising line. That pushes the sample ACF high at many lags even when the fluctuations around the trend are unrelated. Removing the trend, for example by differencing, and then reading the ACF of the remainder shows the real memory.
QuestionA Markov chain run gives 20,000 draws, and its integrated autocorrelation time is estimated at . What is the effective sample size, and what does it mean for the estimate of a mean?Show answer
The effective sample size is . The average of the draws is about as precise as the average of 500 independent draws, not 20,000. The standard error is therefore larger than a naive calculation that ignored autocorrelation would suggest.
Sources
- Autocorrelation (Wikipedia)
- Stationary process (Wikipedia)
- Wiener–Khinchin theorem (Wikipedia)
- Box and Jenkins, Time Series Analysis: Forecasting and Control (1970): https://www.wiley.com/en-us/Time+Series+Analysis%3A+Forecasting+and+Control%2C+5th+Edition-p-9781118675021