Partial Autocorrelation Function PACF
Partial Autocorrelation is the measure of linear correlation between lagged values in a time series independent of the values between the current value and the lagged value. The PACF function helps us determine the impact of individual lagged values to the current value.
Reading sample sales data
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from statsmodels.graphics.tsaplots import plot_acf
%matplotlib inline
%config InlineBackend.figure_format = 'retina'
search_data = pd.read_csv('data/google_search.csv', parse_dates=['Week'])
search_data.head()
| Week | google_search |
|---|---|
| 2022-04-03 | 48 |
| 2022-04-10 | 4 |
| 2022-04-17 | 67 |
| 2022-04-24 | 56 |
| 2022-05-01 | 60 |
fig = plt.figure(figsize=(9,4))
plt.plot(search_data.Week, search_data.google_search)
plt.title('Weekly Good Search: Premier League')
plt.ylabel('Number of Searches')
plt.tight_layout()
Rendering PACF Plot
plot_pacf( sales_data.google_search, lags=20, method='ywm', auto_ylims=True)
plt.tight_layout()