Lesson 2 of 15
Partial Autocorrelation (PACF)
Partial Autocorrelation (PACF)
The Partial Autocorrelation Function (PACF) at lag k measures the correlation between xs[t] and xs[t-k] after removing the effects of all intermediate lags.
PACF is computed using the Levinson-Durbin recursion on the Yule-Walker equations:
φ[1][1] = acf(xs, 1)- For each
k ≥ 2:φ[k][k] = (acf(k) - Σ φ[k-1][j] * acf(k-j)) / (1 - Σ φ[k-1][j] * acf(j))φ[k][j] = φ[k-1][j] - φ[k][k] * φ[k-1][k-j]forj = 1..k-1
pacf(xs, k) = φ[k][k]
PACF cuts off at the AR order — a PACF that drops to zero after lag p suggests an AR(p) model.
Task
Implement pacf(xs, lag) using the Levinson-Durbin recursion.
pacf(xs, 0) = 1.0pacf(xs, 1) = acf(xs, 1)- For higher lags, use the Yule-Walker approach above
Python runtime loading...
Loading...
Click "Run" to execute your code.