Repository: statsmodels/statsmodels (Python)

Issue:
BUG: Change default pacf method
#### Describe the bug
I found the calculated partial autocorrelation would be larger than 1 using sm.graphics.tsa.plot_pacf.

#### Code Sample

```python
import statsmodels.api as sm
import numpy as np
import matplotlib.pyplot as plt
x=np.linspace(0,1,num=512)
f=20
y=np.cos(2*np.pi*f*x)
plt.plot(x,y_trend)
sm.graphics.tsa.plot_pacf(y_trend, lags=25)
```
<details>




Hints:
Change the method to "ywmle" or "old".  The default option here is a poor choice and can produce insane plats.  It should be changed.
Thanks for your reply! It works reasonably after changing the method to 'ols' or 'ywmle'.


Hello @bashtage , is there a plan to change the default pacf method in the future?
Probably by the next release.
Thanks for the quick reply.

Patch:
diff --git a/statsmodels/graphics/tsaplots.py b/statsmodels/graphics/tsaplots.py
--- a/statsmodels/graphics/tsaplots.py
+++ b/statsmodels/graphics/tsaplots.py
@@ -2,6 +2,7 @@
 from statsmodels.compat.pandas import deprecate_kwarg
 
 import calendar
+import warnings
 
 import numpy as np
 import pandas as pd
@@ -245,7 +246,7 @@ def plot_pacf(
     ax=None,
     lags=None,
     alpha=0.05,
-    method="ywadjusted",
+    method=None,
     use_vlines=True,
     title="Partial Autocorrelation",
     zero=True,
@@ -271,15 +272,21 @@ def plot_pacf(
         returned. For instance if alpha=.05, 95 % confidence intervals are
         returned where the standard deviation is computed according to
         1/sqrt(len(x))
-    method : {'ywunbiased', 'ywmle', 'ols'}
+    method : str
         Specifies which method for the calculations to use:
 
-        - yw or ywunbiased : yule walker with bias correction in denominator
-          for acovf. Default.
-        - ywm or ywmle : yule walker without bias correction
-        - ols - regression of time series on lags of it and on constant
-        - ld or ldunbiased : Levinson-Durbin recursion with bias correction
-        - ldb or ldbiased : Levinson-Durbin recursion without bias correction
+        - "ywm" or "ywmle" : Yule-Walker without adjustment. Default.
+        - "yw" or "ywadjusted" : Yule-Walker with sample-size adjustment in
+          denominator for acovf. Default.
+        - "ols" : regression of time series on lags of it and on constant.
+        - "ols-inefficient" : regression of time series on lags using a single
+          common sample to estimate all pacf coefficients.
+        - "ols-adjusted" : regression of time series on lags with a bias
+          adjustment.
+        - "ld" or "ldadjusted" : Levinson-Durbin recursion with bias
+          correction.
+        - "ldb" or "ldbiased" : Levinson-Durbin recursion without bias
+          correction.
 
     use_vlines : bool, optional
         If True, vertical lines and markers are plotted.
@@ -336,6 +343,15 @@ def plot_pacf(
 
     .. plot:: plots/graphics_tsa_plot_pacf.py
     """
+    if method is None:
+        method = "yw"
+        warnings.warn(
+            "The default method 'yw' can produce PACF values outside of "
+            "the [-1,1] interval. After 0.13, the default will change to"
+            "unadjusted Yule-Walker ('ywm'). You can use this method now "
+            "by setting method='ywm'.",
+            FutureWarning,
+        )
     fig, ax = utils.create_mpl_ax(ax)
     vlines_kwargs = {} if vlines_kwargs is None else vlines_kwargs
     lags, nlags, irregular = _prepare_data_corr_plot(x, lags, zero)


Test patch:
diff --git a/statsmodels/graphics/tests/test_tsaplots.py b/statsmodels/graphics/tests/test_tsaplots.py
--- a/statsmodels/graphics/tests/test_tsaplots.py
+++ b/statsmodels/graphics/tests/test_tsaplots.py
@@ -71,8 +71,10 @@ def test_plot_pacf(close_figures):
     armaprocess = tsp.ArmaProcess(ar, ma)
     rs = np.random.RandomState(1234)
     pacf = armaprocess.generate_sample(100, distrvs=rs.standard_normal)
-    plot_pacf(pacf, ax=ax)
-    plot_pacf(pacf, ax=ax, alpha=None)
+    with pytest.warns(FutureWarning):
+        plot_pacf(pacf, ax=ax)
+    with pytest.warns(FutureWarning, match="The default"):
+        plot_pacf(pacf, ax=ax, alpha=None)
 
 
 @pytest.mark.matplotlib
@@ -88,20 +90,23 @@ def test_plot_pacf_kwargs(close_figures):
     pacf = armaprocess.generate_sample(100, distrvs=rs.standard_normal)
 
     buff = BytesIO()
-    plot_pacf(pacf, ax=ax)
+    with pytest.warns(FutureWarning, match="The default"):
+        plot_pacf(pacf, ax=ax)
     fig.savefig(buff, format="rgba")
 
     buff_linestyle = BytesIO()
     fig_linestyle = plt.figure()
     ax = fig_linestyle.add_subplot(111)
-    plot_pacf(pacf, ax=ax, ls="-")
+    with pytest.warns(FutureWarning, match="The default"):
+        plot_pacf(pacf, ax=ax, ls="-")
     fig_linestyle.savefig(buff_linestyle, format="rgba")
 
     buff_with_vlines = BytesIO()
     fig_with_vlines = plt.figure()
     ax = fig_with_vlines.add_subplot(111)
     vlines_kwargs = {"linestyles": "dashdot"}
-    plot_pacf(pacf, ax=ax, vlines_kwargs=vlines_kwargs)
+    with pytest.warns(FutureWarning, match="The default"):
+        plot_pacf(pacf, ax=ax, vlines_kwargs=vlines_kwargs)
     fig_with_vlines.savefig(buff_with_vlines, format="rgba")
 
     buff.seek(0)
@@ -185,9 +190,12 @@ def test_plot_pacf_irregular(close_figures):
     armaprocess = tsp.ArmaProcess(ar, ma)
     rs = np.random.RandomState(1234)
     pacf = armaprocess.generate_sample(100, distrvs=rs.standard_normal)
-    plot_pacf(pacf, ax=ax, lags=np.arange(1, 11))
-    plot_pacf(pacf, ax=ax, lags=10, zero=False)
-    plot_pacf(pacf, ax=ax, alpha=None, zero=False)
+    with pytest.warns(FutureWarning, match="The default"):
+        plot_pacf(pacf, ax=ax, lags=np.arange(1, 11))
+    with pytest.warns(FutureWarning, match="The default"):
+        plot_pacf(pacf, ax=ax, lags=10, zero=False)
+    with pytest.warns(FutureWarning, match="The default"):
+        plot_pacf(pacf, ax=ax, alpha=None, zero=False)
 
 
 @pytest.mark.matplotlib