ACF/PACF in Python

ECON 3209 · Week 19, Lecture 3 · Kerala Agricultural University

Department of Development Economics, KAU

Autumn 2026

Learning Outcomes

By the end of this lecture, you should be able to:

  1. define the autocorrelation function (ACF) and partial autocorrelation function (PACF)
  2. use ACF/PACF patterns to identify AR and MA orders
  3. generate lag plots and correlograms in Python
  4. compare AR(1) and MA(1) signatures visually
  5. connect ACF/PACF evidence to model selection for forecasting

What Is the ACF?

  • The autocorrelation function measures correlation between \(Y_t\) and \(Y_{t-k}\) for each lag \(k\).
  • It shows how long dependence persists.
  • A slowly decaying ACF often suggests an autoregressive pattern or nonstationarity.

What Is the PACF?

  • The partial autocorrelation function measures the direct relationship between \(Y_t\) and \(Y_{t-k}\) after removing intermediate lags.
  • PACF is especially useful for identifying AR order.
  • A sharp cutoff in PACF after lag \(p\) often suggests an AR(\(p\)) process.

Identification Rules of Thumb

  • AR(p): PACF cuts off after lag \(p\), ACF tails off.
  • MA(q): ACF cuts off after lag \(q\), PACF tails off.
  • ARMA: both ACF and PACF usually tail off.
  • These are heuristics, not mechanical laws.

Simulating AR(1) and MA(1)

ACF and PACF Plots

Lag Plot Idea

  • A lag plot graphs \(Y_t\) against \(Y_{t-1}\) or another lagged value.
  • If points cluster along an upward line, persistence is positive.
  • If points are a cloud with no structure, serial dependence is weak.

Lag Plot in Python

Kerala Series Example

For Kerala monthly rubber prices, a strong positive ACF at low lags suggests persistence.

PACF helps us judge whether a simple AR(1) or AR(2) structure may be enough before estimating an ARIMA model.

Manual Correlations by Lag

From Diagnostics to Model Orders

  • ACF/PACF do not choose the final model alone.
  • Use them with stationarity tests, information criteria, and forecast performance.
  • But they remain a core visual tool for understanding the data-generating process.

Exercise

Generate an AR(1) or MA(1) process with the starter code. Then inspect the ACF/PACF and explain which order pattern you see.

Summary

  • ✅ ACF measures total serial correlation across lags, while PACF isolates direct lag effects.
  • ✅ Their cutoff and decay patterns help identify AR and MA orders.
  • ✅ Lag plots give a simple visual check of persistence.
  • ✅ These diagnostics prepare us to build ARIMA models for forecasting.

Next Lecture

  • We begin forecasting with AR, MA, and ARIMA models.
  • You will combine differencing, ACF/PACF evidence, and information criteria.
  • This is the main forecasting toolkit for the final week.