Using packages:
from statsmodels.graphics.tsaplots import plot_acf, plot_pacf
from statsmodels.tsa.stattools import acf, pacf
Performing manual and built-in plot utils, give different values. No, I don't mean picture scale, but the actual value seems different between manual plot and plotting PACF with built-in tools:
len_of_pacf = len(entire_mid)//4
# Using built-in
plot_acf(entire_mid, lags=len(entire_mid)-1)
plot_pacf(entire_mid, lags=len_of_pacf-1)
plt.show()
# Manual plotting
acf_result = acf(entire_mid, nlags=len(entire_mid))
pacf_result = pacf(entire_mid, nlags=len_of_pacf)
plt.plot(acf_result)
plt.plot(pacf_result)
plt.show()
Returning:
The ACF itself working fine, it returning same output, but not the PACF. I mean, it's uncommon the minimum value of PACF is under -1.
Turns out because of different method of calculation.
method=ywm
# statsmodels.graphics.tsaplots.plot_pacf
def plot_pacf(
x,
ax=None,
lags=None,
alpha=0.05,
method="ywm",
use_vlines=True,
title="Partial Autocorrelation",
zero=True,
vlines_kwargs=None,
**kwargs,
):
"""
Plot the partial autocorrelation function
Parameters
----------
x : array_like
...
method=ywadjusted
# statsmodels.tsa.stattools.pacf
def pacf(
x: ArrayLike1D,
nlags: int | None = None,
method: Literal[
"yw",
"ywadjusted",
"ols",
"ols-inefficient",
"ols-adjusted",
"ywm",
"ywmle",
"ld",
"ldadjusted",
"ldb",
"ldbiased",
"burg",
] = "ywadjusted",
alpha: float | None = None,
) -> np.ndarray | tuple[np.ndarray, np.ndarray]:
"""
Partial autocorrelation estimate.
Parameters
----------
...