Autocorrelation function (ACF): how to read it, with example
Autocorrelation is the correlation of a time series with itself shifted by k periods (the lag). The autocorrelation function (ACF) lists it for lags 1, 2, 3 and so on. A large lag-1 autocorrelation means each value resembles the one before it, as in a chemical bath, a furnace temperature or a slowly wearing tool. The ACF answers two questions: are consecutive observations independent, as most control charts and tests assume, and if not, what kind of time series model describes them?
When to use it
- Before building a control chart or running a test that assumes independent observations, especially for continuous processes sampled often.
- To check whether a forecasting or regression model left a pattern in its residuals.
- To identify an ARIMA model: the shape of the ACF, together with the partial autocorrelation, suggests the model's order.
- To find seasonality: a spike at lag 12 in monthly data, or lag 7 in daily data, points to a repeating cycle.
How it works
For a series y₁, …, yₙ with mean ȳ, the autocorrelation at lag k is:
rₖ = Σₜ₌₁ⁿ⁻ᵏ (yₜ − ȳ)(yₜ₊ₖ − ȳ) / Σₜ₌₁ⁿ (yₜ − ȳ)²It ranges from −1 to 1, like an ordinary correlation. For a purely random series, every rₖ is close to 0, and about 95% of them fall within the approximate bounds:
± 2 / √nA more careful version, Bartlett's formula, widens the bound at lag k to account for the autocorrelations at smaller lags: SEₖ = √[(1 + 2·(r₁² + … + rₖ₋₁²)) / n], and the bound is ±2·SEₖ.
To test many lags at once, the Ljung–Box statistic combines the first K autocorrelations:
Q = n(n + 2) · Σₖ₌₁ᴷ rₖ² / (n − k)If the series is random, Q follows approximately a chi-square distribution with K degrees of freedom. When Q is computed on the residuals of a fitted ARMA model, subtract the number of estimated coefficients from K.
Example
An electroplating line measures the brightener additive in its nickel bath every hour. Fifty readings (g/L), in order:
4.16, 3.94, 3.98, 4.13, 4.10, 4.19, 4.42, 4.33, 4.19, 4.04, 4.11, 4.05, 4.02, 4.00, 4.08, 3.93, 3.76, 3.54, 3.82, 3.89, 4.10, 4.07, 3.96, 4.03, 4.01, 3.86, 3.79, 4.07, 4.09, 4.11, 4.05, 3.95, 4.07, 4.04, 3.94, 3.94, 3.85, 3.92, 4.08, 3.95, 4.14, 4.02, 4.03, 3.92, 3.92, 3.95, 3.91, 3.85, 3.82, 3.77
The mean is 3.998 g/L and the standard deviation 0.148. For lag 1, the sum of products of neighboring deviations is 0.6714 and the sum of squared deviations is 1.0703, so r₁ = 0.6714 / 1.0703 = 0.627.
The bound is ±2/√50 = ±0.283. Lags 1 and 2 are clearly beyond it, and the ACF dies out gradually (0.627, 0.343, 0.140), the pattern of a first-order autoregressive process. Lag 11, at −0.292, is just past ±0.283, but Bartlett's bound at lag 11 is ±0.415, so it is consistent with chance. The Ljung–Box test agrees that the series is not random:
| Lags K | Q | df | p-value |
|---|---|---|---|
| 6 | 28.49 | 6 | 0.00008 |
| 12 | 40.26 | 12 | 0.00007 |
Why it matters. An I-MR chart estimates sigma from the average moving range: here 0.0973 / 1.128 = 0.086 g/L, much smaller than the overall standard deviation of 0.148, because neighboring readings are similar. Limits based on 0.086 would be too narrow for the slow wandering of the bath, and the chart would signal often for no assignable cause. The team can sample less often, chart the residuals of a time series model, or use a chart designed for autocorrelated data. The ARIMA article fits a model to this same series.
How to read the results
- A slow, geometric decay suggests an autoregressive process, or a trend or level shift if the decay is very slow.
- A sharp cutoff after lag q suggests a moving average process of order q.
- Spikes at the seasonal lag (4, 12, 7) mean a seasonal pattern.
- Alternating signs suggest overcorrection, such as an operator adjusting after every reading.
- One bar slightly past ±2/√n among many lags is expected by chance: with 20 lags, about one will cross.
Common mistakes
- Running the ACF on a trending series. A trend makes every lag positive and hides the structure; difference or detrend first.
- Using too few observations. With n below about 50, the bounds are wide and the ACF is unreliable beyond a few lags.
- Looking at too many lags. A common guide is up to about n/4 lags.
- Treating autocorrelation as a special cause. It is a property of the process. Ignoring it in a control chart produces false alarms; a runs test on the same data would also flag non-randomness.
Frequently asked questions
What is a "significant" autocorrelation?
One beyond the ±2/√n bound, or beyond Bartlett's wider bound for higher lags. Treat a single borderline lag with caution and look at the overall pattern and the Ljung–Box test.
Why is r₁ not exactly the Pearson correlation of yₜ with yₜ₊₁?
The ACF uses the overall mean and the overall sum of squares in the denominator, rather than separate means for the two shifted pieces. The two numbers are close for long series.
What is the difference between ACF and PACF?
The ACF at lag k includes indirect links through the lags in between; the partial autocorrelation removes them. An AR(1) process has an ACF that decays slowly and a PACF that cuts off after lag 1.
Can I use the ACF to check regression residuals?
Yes. If residuals in time order show autocorrelation, standard errors and p-values from the regression are too small, and a time series model or a lagged term may be needed.