ACF & PACF: Reading the Correlogram
The correlogram — the side-by-side plot of the Autocorrelation Function (ACF) and Partial Autocorrelation Function (PACF) — is the single most important diagnostic tool in classical time series analysis. Reading it correctly lets you identify the order of an AR, MA, or ARMA model without fitting anything.
The autocorrelation function
Given a weakly stationary series with mean and variance , the autocovariance at lag is:
The autocorrelation at lag normalises this to the range :
Note always, and (symmetry), so we only plot .
Sample estimate. Given observations :
The ACF captures the total correlation between and , including indirect paths through all intermediate lags .
The partial autocorrelation function
The PACF removes these indirect paths. Formally, the partial autocorrelation at lag is the correlation between and after linearly controlling for :
where denotes the projection onto the linear span of .
Computing the PACF via the Yule-Walker equations
For a stationary series the PACF values can be computed recursively using the Durbin-Levinson algorithm, which solves the Yule-Walker system at each lag:
At lag 1:
At lag 2 (Yule-Walker):
Solving: .
In general, the -th PACF coefficient is the last element of the solution to the Yule-Walker system:
where is the autocovariance matrix and .
Significance bands on the plots
Under the white-noise null hypothesis ( is i.i.d.), all autocorrelations for are zero, and the sample estimates are approximately normally distributed with standard deviation for large .
The standard 95% confidence bands are:
Any spike outside these bands is considered statistically significant at the 5% level.
Bartlett's formula provides a more refined standard error that accounts for the correlation structure when the series is not white noise:
Statsmodels uses Bartlett's formula by default in plot_acf, which is why the confidence bands widen slightly at larger lags when the series has significant autocorrelation at earlier lags.
Reading AR, MA, and ARMA orders from the patterns
This is the core skill. After differencing the series to stationarity, match the ACF/PACF pattern to a model family:
| ACF pattern | PACF pattern | Model suggested |
|---|---|---|
| Exponential decay (positive or alternating) | Cuts off sharply after lag | AR() |
| Cuts off sharply after lag | Exponential decay (positive or alternating) | MA() |
| Tails off gradually (exponential or damped sinusoidal) | Tails off gradually | ARMA(, ) |
| All spikes within bands at all lags | All spikes within bands at all lags | White noise: model fitted |
| Slow, linear decay: spikes stay significant for many lags | Large spike at lag 1 | Non-stationary: difference again |
| Significant spikes at lags (seasonal) | Spike at seasonal lag | Seasonal component: use SARIMA |
Reading 'cuts off' vs 'tails off'
Cuts off means the ACF (or PACF) drops to zero abruptly at some lag and all subsequent spikes are inside the confidence bands. Tails off means the spikes decrease gradually and may remain statistically significant for many lags. The distinction is key: a MA(2) ACF cuts off at lag 2; an AR(2) ACF tails off with exponentially decaying spikes.
Computing the ACF at lags 1–3 by hand
Series: , so .
Step 1 — compute the mean:
Step 2: compute deviations :
| 1 | 1 | |
| 2 | 3 | |
| 3 | 2 | |
| 4 | 4 | |
| 5 | 3 | |
| 6 | 5 |
Step 3: variance (denominator for all autocorrelations):
Step 4: autocovariance at lag 1 (sum over pairs for ):
Step 5: autocovariance at lag 2 (pairs for ):
Step 6: autocovariance at lag 3 (pairs for ):
Summary:
| Lag | |
|---|---|
| 0 | 1.00 |
| 1 | |
| 2 | |
| 3 |
Significance bands: . All three lags fall inside the bands — for this tiny sample, none are significant. With more data, the alternating positive-negative pattern might suggest an MA(1) or AR(1) with a negative coefficient.
Step through the recursion
The worked example above stops at the ACF. The trace carries it into the PACF via Durbin-Levinson, then measures how reliable the pattern table actually is.
ACF and PACF — the recursion, and how often the correlogram lies
The page's hand-worked series, recomputed: ȳ = 3, deviations (-2, 0, -1, 1, 0, 2), γ₀ = 10. That gives ρ̂₁ = -0.10, ρ̂₂ = 0.40, ρ̂₃ = -0.40 — matching the page exactly. Note the denominator: **every lag divides by the same γ₀**, computed over all 6 points, while the numerator at lag k sums only 6 − k products. That asymmetry is deliberate; it guarantees the estimated ACF is a valid (positive semi-definite) autocorrelation sequence, which the "unbiased" alternative does not.
The page's hand-worked ACF on [1,3,2,4,3,5] reproduced exactly, then the Durbin-Levinson recursion carried past lag 2 where the page stops giving formulas, with every value cross-checked against a direct solve of the Yule-Walker system. The payoff measures the pattern table itself: over 600 replicates the AR(2) PACF satisfies 'cuts off at lag 2' 67.5% of the time at ten lags and 38.8% at twenty, and more data does not help — the ceiling is 0.95^(L-2) from inspecting L lags at a 5% level, matched to within 1.2 percentage points at three values of L. The MA(2) case falls below even that, which is precisely what the page's Bartlett remark is for.
What to notice:
- Frame 2: what the PACF subtracts. At lag 2 the numerator is : the total correlation minus the part already explained by routing through lag 1. On this series , so the indirect path is negligible and .
- Frame 3: past where the formulas stop. The recursion reaches without building or inverting the system, and agrees with a direct solve to . It also carries the shorter model's coefficients forward, which is why the whole PACF costs rather than a fresh solve per lag.
- Frame 5: the payoff, and it is a caution. Over 600 replicates the AR(2) PACF satisfies "cuts off at lag 2" 68.7% of the time when 10 lags are inspected, and 38.5% at 20. More data does not help: the ceiling is , because "inside the band at every later lag" is independent 5% tests. Inspecting more lags makes the diagnosis less reliable, not more.
- Frame 6: why the band matters. With the naive band the MA(2) ACF reads correctly only 55.3% of the time, below even that ceiling, because the band assumes white noise while the significant inflate the true standard error at later lags. Bartlett's SE recovers it to 67.8%.
So the correlogram proposes an order; it does not confirm one. Inspect few lags, expect a stray spike, and let the information criteria and residual checks decide, which is exactly the workflow the Box-Jenkins page lays out.
Seasonal patterns in the correlogram
When the series has a seasonal period (e.g. for monthly data), the ACF shows spikes at multiples of the seasonal lag: significant , , , and so on. The PACF typically shows a single large spike at lag with smaller spikes at .
This pattern survives even after non-seasonal differencing and signals the need for seasonal differencing and seasonal AR/MA terms in a SARIMA model.
Computing all of this in Python
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from statsmodels.tsa.stattools import acf, pacf
from statsmodels.graphics.tsaplots import plot_acf, plot_pacf
# ── Manual ACF computation matching the worked example ────────────────────────
def manual_acf(series, max_lag):
y = np.array(series, dtype=float)
T = len(y)
y_bar = y.mean()
d = y - y_bar
gamma_0 = np.sum(d**2)
rho = [1.0]
for k in range(1, max_lag + 1):
gamma_k = np.sum(d[k:] * d[:-k])
rho.append(gamma_k / gamma_0)
return np.array(rho)
series_example = [1, 3, 2, 4, 3, 5]
print("Manual ACF lags 0-3:", manual_acf(series_example, 3))
# [ 1. -0.1 0.4 -0.4]
# ── Statsmodels ACF and PACF ──────────────────────────────────────────────────
np.random.seed(42)
T = 200
# Simulate AR(2): y_t = 0.6 y_{t-1} - 0.3 y_{t-2} + eps
eps = np.random.normal(0, 1, T)
y_ar2 = np.zeros(T)
for t in range(2, T):
y_ar2[t] = 0.6 * y_ar2[t-1] - 0.3 * y_ar2[t-2] + eps[t]
fig, axes = plt.subplots(1, 2, figsize=(12, 4))
plot_acf( y_ar2, lags=20, ax=axes[0], title="AR(2) — ACF (should tail off)")
plot_pacf(y_ar2, lags=20, ax=axes[1], title="AR(2) — PACF (should cut off at lag 2)")
plt.tight_layout()
plt.show()
# Simulate MA(2): y_t = eps_t + 0.5 eps_{t-1} - 0.4 eps_{t-2}
eps = np.random.normal(0, 1, T)
y_ma2 = eps.copy()
for t in range(2, T):
y_ma2[t] = eps[t] + 0.5 * eps[t-1] - 0.4 * eps[t-2]
fig, axes = plt.subplots(1, 2, figsize=(12, 4))
plot_acf( y_ma2, lags=20, ax=axes[0], title="MA(2) — ACF (should cut off at lag 2)")
plot_pacf(y_ma2, lags=20, ax=axes[1], title="MA(2) — PACF (should tail off)")
plt.tight_layout()
plt.show()
# ── Raw ACF/PACF values ───────────────────────────────────────────────────────
acf_vals = acf(y_ar2, nlags=10)
pacf_vals = pacf(y_ar2, nlags=10)
bands = 1.96 / np.sqrt(T)
print("\nAR(2) ACF at lags 0-5:", np.round(acf_vals[:6], 3))
print("AR(2) PACF at lags 0-5:", np.round(pacf_vals[:6], 3))
print(f"95% bands: ±{bands:.3f}")
Related concepts
- Time Series Fundamentals: stationarity, differencing, and the motivation for looking at autocorrelation
- ARIMA Models: uses ACF/PACF patterns to select and
- ARIMA Order Selection: Box-Jenkins Methodology: the full four-phase procedure that builds on these plots