Understanding the autocorrelation (ACF) calculator — concept and principle
The autocorrelation function (ACF) measures how strongly a time series is correlated with a shifted copy of itself. The value at lag k answers: if this period is above average, how likely is the period k steps later to be above average too? Analysts use it to detect trends, seasonality and leftover structure in model residuals.
How it is calculated
- Mean: x̄ = Σxₜ ÷ n.
- ACF at lag k: rₖ = Σ (xₜ − x̄)(xₜ₊ₖ − x̄) ÷ Σ (xₜ − x̄)². The top sum runs over the n − k overlapping pairs; the bottom sum uses all n values.
- 95% significance bound = 1.96 ÷ √n.
The calculator reports lags 1 to the "max lag" you choose. rₖ is unitless and lies between −1 and 1.
The principle
The ACF is a correlation coefficient computed between the series and its lagged self. Using the full-series variance in the denominator is the standard Box-Jenkins estimator; it slightly shrinks values at large lags. If the series were pure white noise, each rₖ would be approximately normal with mean 0 and standard deviation 1/√n, so values outside ±1.96/√n are unusual at the 5% level. A slowly decaying ACF suggests a trend; peaks at lags 12 or 4 suggest monthly or quarterly seasonality.
Worked example
- Series: 5, 7, 6, 8, 9, 8, 10, 11, 10, 12 (n = 10), max lag 4.
- Mean x̄ = 86 ÷ 10 = 8.6. Deviations: −3.6, −1.6, −2.6, −0.6, 0.4, −0.6, 1.4, 2.4, 1.4, 3.4.
- Denominator: sum of squared deviations = 44.4.
- Lag-products sums: lag 1 = 21.64, lag 2 = 18.88, lag 3 = 7.12, lag 4 = −7.04.
- ACF: lag 1: 0.4874 · lag 2: 0.4252 · lag 3: 0.1604 · lag 4: −0.1586.
- Bound: 1.96 ÷ √10 ≈ 0.6198064214.
How to read the result
Here no lag exceeds ±0.62, so with only 10 points none is individually significant, even though the series clearly rises. That illustrates how wide the bound is for short series. For a series with a trend, the ACF typically starts high and decays slowly; differencing (taking xₜ − xₜ₋₁) usually removes this. For model residuals, you want all lags inside the bound.
Common mistakes
- Reading many lags and treating one that crosses the bound as meaningful; about 1 in 20 will by chance.
- Interpreting the ACF of a trending series as seasonality or persistence without removing the trend first.
- Confusing the ACF with the PACF, which removes the effect of shorter lags.
Frequently asked questions
Why do software packages give slightly different ACF values?
Some divide each lag's sum by n − k instead of using the full-series formula, or use a different bound such as Bartlett's formula.
What is the difference between ACF and PACF?
The PACF at lag k is the correlation that remains after removing the influence of lags 1 to k − 1; it is used to choose the order of AR models.
Sources: G. E. P. Box, G. M. Jenkins, G. C. Reinsel and G. M. Ljung, Time Series Analysis: Forecasting and Control, 5th ed., Wiley, 2015 · R. J. Hyndman and G. Athanasopoulos, Forecasting: Principles and Practice, 3rd ed., OTexts, 2021, Section 2.8