๐ ACF vs PACF – Complete Guide for Time Series Analysis
If you're working with time series data, two tools you’ll constantly encounter are ACF (Auto-Correlation Function) and PACF (Partial Auto-Correlation Function). These help you understand how past values influence the present.
๐ Table of Contents
- What is ACF?
- What is PACF?
- Mathematics Explained
- Code Example
- CLI Output
- ACF vs PACF
- Practical Use Cases
- Key Takeaways
- Related Articles
๐ What is ACF?
The Auto-Correlation Function (ACF) measures how a time series is related to its past values.
It answers: "How similar is the current value to previous values?"
๐ฏ What is PACF?
PACF removes indirect effects and shows only the direct relationship between a value and a lag.
It answers: "What is the direct impact of a specific past value?"
๐ Mathematics Explained (Easy Language)
1. ACF Formula
\[ \rho_k = \frac{Cov(Y_t, Y_{t-k})}{Var(Y_t)} \]
Simple Explanation:
- \(Y_t\) = current value
- \(Y_{t-k}\) = value k steps back
- Cov = how two values move together
๐ ACF checks how strongly past values move with the current value.
2. PACF Concept
PACF removes intermediate effects using regression.
\[ Y_t = \phi_1 Y_{t-1} + \phi_2 Y_{t-2} + \dots + \epsilon_t \]
Explanation:
- \(\phi\) = direct impact of each lag
- \(\epsilon_t\) = random noise
๐ป Code Example (Python)
import pandas as pd
import matplotlib.pyplot as plt
from statsmodels.graphics.tsaplots import plot_acf, plot_pacf
data = [10,12,13,15,18,20,22,21,19,18]
plot_acf(data)
plot_pacf(data)
plt.show()
๐ฅ️ CLI Output (Interpretation)
Click to Expand
ACF Plot: Lag 1: High correlation Lag 2: Moderate Lag 3+: Gradual decline PACF Plot: Lag 1: Strong spike Lag 2+: Drops quickly
⚖️ ACF vs PACF
| Feature | ACF | PACF |
|---|---|---|
| Measures | Total correlation | Direct correlation |
| Includes indirect effects | Yes | No |
| Used for | MA models | AR models |
๐ Practical Use Case
In ARIMA modeling:
- ACF helps identify q (MA order)
- PACF helps identify p (AR order)
๐ก Key Takeaways
- ACF shows overall relationship with past values
- PACF isolates direct relationships
- Both are essential for time series modeling
- Used heavily in ARIMA forecasting
๐ฏ Final Thoughts
ACF and PACF are like diagnostic tools for your data. One shows the big picture, the other zooms into specific relationships.
Once you understand both, you unlock the ability to build powerful forecasting models.
No comments:
Post a Comment