ACF & PACF: Reading the CorrelogramOpen in Colab

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 {yt}\{y_t\} with mean μ\mu and variance σ2\sigma^2, the autocovariance at lag kk is:

γk=Cov(yt, yt−k)=E[(yt−μ)(yt−k−μ)]\gamma_k = \text{Cov}(y_t,\, y_{t-k}) = \mathbb{E}[(y_t - \mu)(y_{t-k} - \mu)]

The autocorrelation at lag kk normalises this to the range [−1,1][-1, 1]:

ρk=γkγ0=Cov(yt,yt−k)Var(yt)\rho_k = \frac{\gamma_k}{\gamma_0} = \frac{\text{Cov}(y_t, y_{t-k})}{\text{Var}(y_t)}

Note ρ0=1\rho_0 = 1 always, and ρk=ρ−k\rho_k = \rho_{-k} (symmetry), so we only plot k≥0k \ge 0.

Sample estimate. Given TT observations y1,…,yTy_1, \ldots, y_T:

ρ^k=∑t=k+1T(yt−yˉ)(yt−k−yˉ)∑t=1T(yt−yˉ)2\hat{\rho}_k = \frac{\sum_{t=k+1}^{T}(y_t - \bar{y})(y_{t-k} - \bar{y})}{\sum_{t=1}^{T}(y_t - \bar{y})^2}

The ACF captures the total correlation between yty_t and yt−ky_{t-k}, including indirect paths through all intermediate lags yt−1,yt−2,…,yt−k+1y_{t-1}, y_{t-2}, \ldots, y_{t-k+1}.

The partial autocorrelation function

The PACF removes these indirect paths. Formally, the partial autocorrelation at lag kk is the correlation between yty_t and yt−ky_{t-k} after linearly controlling for yt−1,yt−2,…,yt−k+1y_{t-1}, y_{t-2}, \ldots, y_{t-k+1}:

ϕkk=Corr(yt−P^k−1[yt],  yt−k−P^k−1[yt−k])\phi_{kk} = \text{Corr}(y_t - \hat{P}_{k-1}[y_t],\; y_{t-k} - \hat{P}_{k-1}[y_{t-k}])

where P^k−1[⋅]\hat{P}_{k-1}[\cdot] denotes the projection onto the linear span of yt−1,…,yt−k+1y_{t-1}, \ldots, y_{t-k+1}.

Computing the PACF via the Yule-Walker equations

For a stationary series the PACF values ϕ11,ϕ22,…\phi_{11}, \phi_{22}, \ldots can be computed recursively using the Durbin-Levinson algorithm, which solves the Yule-Walker system at each lag:

At lag 1: ϕ11=ρ1\phi_{11} = \rho_1

At lag 2 (Yule-Walker):

(ρ1ρ2)=(1ρ1ρ11)(ϕ21ϕ22)\begin{pmatrix} \rho_1 \\ \rho_2 \end{pmatrix} = \begin{pmatrix} 1 & \rho_1 \\ \rho_1 & 1 \end{pmatrix} \begin{pmatrix} \phi_{21} \\ \phi_{22} \end{pmatrix}

Solving: ϕ22=(ρ2−ρ12)/(1−ρ12)\phi_{22} = (\rho_2 - \rho_1^2) / (1 - \rho_1^2).

In general, the kk-th PACF coefficient ϕkk\phi_{kk} is the last element of the solution to the k×kk \times k Yule-Walker system:

Γkϕk=ρk\boldsymbol{\Gamma}_k \boldsymbol{\phi}_k = \boldsymbol{\rho}_k

where (Γk)ij=ρ∣i−j∣(\boldsymbol{\Gamma}_k)_{ij} = \rho_{|i-j|} is the autocovariance matrix and ρk=[ρ1,ρ2,…,ρk]⊤\boldsymbol{\rho}_k = [\rho_1, \rho_2, \ldots, \rho_k]^\top.

Significance bands on the plots

Under the white-noise null hypothesis (yty_t is i.i.d.), all autocorrelations ρk\rho_k for k>0k > 0 are zero, and the sample estimates ρ^k\hat{\rho}_k are approximately normally distributed with standard deviation 1/T1/\sqrt{T} for large TT.

The standard 95% confidence bands are:

±1.96T\pm \frac{1.96}{\sqrt{T}}

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:

SE(ρ^k)≈1+2∑j=1k−1ρ^j2T\text{SE}(\hat{\rho}_k) \approx \sqrt{\frac{1 + 2\sum_{j=1}^{k-1}\hat{\rho}_j^2}{T}}

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 patternPACF patternModel suggested
Exponential decay (positive or alternating)Cuts off sharply after lag ppAR(pp)
Cuts off sharply after lag qqExponential decay (positive or alternating)MA(qq)
Tails off gradually (exponential or damped sinusoidal)Tails off graduallyARMA(pp, qq)
All spikes within bands at all lagsAll spikes within bands at all lagsWhite noise: model fitted
Slow, linear decay: spikes stay significant for many lagsLarge spike at lag 1Non-stationary: difference again
Significant spikes at lags s,2s,3s,…s, 2s, 3s, \ldots (seasonal)Spike at seasonal lag ssSeasonal 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: [1,3,2,4,3,5][1, 3, 2, 4, 3, 5], so T=6T = 6.

Step 1 — compute the mean: yˉ=1+3+2+4+3+56=186=3\bar{y} = \frac{1 + 3 + 2 + 4 + 3 + 5}{6} = \frac{18}{6} = 3

Step 2: compute deviations dt=yt−yˉd_t = y_t - \bar{y}:

ttyty_tdt=yt−3d_t = y_t - 3
11−2-2
2300
32−1-1
4411
5300
6522

Step 3: variance (denominator for all autocorrelations): γ0=∑t=16dt2=(−2)2+02+(−1)2+12+02+22=4+0+1+1+0+4=10\gamma_0 = \sum_{t=1}^6 d_t^2 = (-2)^2 + 0^2 + (-1)^2 + 1^2 + 0^2 + 2^2 = 4 + 0 + 1 + 1 + 0 + 4 = 10

Step 4: autocovariance at lag 1 (sum over pairs (t,t−1)(t, t-1) for t=2,…,6t = 2, \ldots, 6): γ1=∑t=26dt⋅dt−1=(0)(−2)+(−1)(0)+(1)(−1)+(0)(1)+(2)(0)=0+0−1+0+0=−1\gamma_1 = \sum_{t=2}^{6} d_t \cdot d_{t-1} = (0)(-2) + (-1)(0) + (1)(-1) + (0)(1) + (2)(0) = 0 + 0 - 1 + 0 + 0 = -1 ρ1=−110=−0.10\rho_1 = \frac{-1}{10} = -0.10

Step 5: autocovariance at lag 2 (pairs (t,t−2)(t, t-2) for t=3,…,6t = 3, \ldots, 6): γ2=∑t=36dt⋅dt−2=(−1)(−2)+(1)(0)+(0)(−1)+(2)(1)=2+0+0+2=4\gamma_2 = \sum_{t=3}^{6} d_t \cdot d_{t-2} = (-1)(-2) + (1)(0) + (0)(-1) + (2)(1) = 2 + 0 + 0 + 2 = 4 ρ2=410=0.40\rho_2 = \frac{4}{10} = 0.40

Step 6: autocovariance at lag 3 (pairs (t,t−3)(t, t-3) for t=4,5,6t = 4, 5, 6): γ3=∑t=46dt⋅dt−3=(1)(−2)+(0)(0)+(2)(−1)=−2+0−2=−4\gamma_3 = \sum_{t=4}^{6} d_t \cdot d_{t-3} = (1)(-2) + (0)(0) + (2)(-1) = -2 + 0 - 2 = -4 ρ3=−410=−0.40\rho_3 = \frac{-4}{10} = -0.40

Summary:

Lag kkρ^k\hat{\rho}_k
01.00
1−0.10-0.10
20.400.40
3−0.40-0.40

Significance bands: ±1.96/6≈±0.80\pm 1.96 / \sqrt{6} \approx \pm 0.80. All three lags fall inside the bands — for this tiny T=6T = 6 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

1/6

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.

python
1# Durbin-Levinson: phi_kk from the ACF
2phi = [rho[1]] # phi_11
3pacf = [rho[1]]
4
5for k in range(2, K + 1):
6 # numerator: rho_k minus what the
7 # shorter model already explains
8 num = rho[k]
9 den = 1.0
10 for j in range(1, k):
11 num -= phi[j - 1] * rho[k - j]
12 den -= phi[j - 1] * rho[j]
13 phi_kk = num / den
14
15 # update the shorter coefficients
16 phi = [phi[j] - phi_kk * phi[k - 2 - j]
17 for j in range(k - 1)] + [phi_kk]
18 pacf.append(phi_kk)
state
y → deviations from the mean
1-2
30
2-1
41
30
52
sample ACF (band ±0.80 at T = 6)
ρ1
-0.10
ρ2
0.40
ρ3
-0.40

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 ρ^2−ρ^12\hat\rho_2 - \hat\rho_1^2: the total correlation minus the part already explained by routing through lag 1. On this series ρ^12=0.01\hat\rho_1^2 = 0.01, so the indirect path is negligible and ϕ22≈ρ^2\phi_{22} \approx \hat\rho_2.
  • Frame 3: past where the formulas stop. The recursion reaches ϕ33=−0.4022\phi_{33} = -0.4022 without building or inverting the 3×33\times3 system, and agrees with a direct solve to 10−1610^{-16}. It also carries the shorter model's coefficients forward, which is why the whole PACF costs O(K2)O(K^2) rather than a fresh O(k3)O(k^3) 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 0.95L−20.95^{L-2}, because "inside the band at every later lag" is L−2L-2 independent 5% tests. Inspecting more lags makes the diagnosis less reliable, not more.
  • Frame 6: why the band matters. With the naive ±1.96/T\pm 1.96/\sqrt{T} 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 ρ1,ρ2\rho_1, \rho_2 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 mm (e.g. m=12m = 12 for monthly data), the ACF shows spikes at multiples of the seasonal lag: significant ρ^12\hat{\rho}_{12}, ρ^24\hat{\rho}_{24}, ρ^36\hat{\rho}_{36}, and so on. The PACF typically shows a single large spike at lag mm with smaller spikes at 2m2m.

This pattern survives even after non-seasonal differencing and signals the need for seasonal differencing Δ12yt=yt−yt−12\Delta_{12} y_t = y_t - y_{t-12} and seasonal AR/MA terms in a SARIMA model.

Computing all of this in Python

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

Concept neighbourhood

How this concept connects — click any node to jump there, or explore the whole concept map.

RelatedReferenced by
ACF & PACF: Reading the Correlogr…ARIMA Order Selection: Bo…Time Series FundamentalsARIMA Models