Repository: statsmodels/statsmodels

Issue:
plot_acf doesn't forward missing to acf
`plot_acf` forwards its `alpha`, `fft` and `unbiased` arguments to `acf()`. However `acf` also accepts `missing` which isn't forwarded.

This means I cannot use plot_acf() on data with gaps (represented by NaN) since I cannot pass missing='conservative'

If I have time I'll create a pull request but I cannot promise when I'll get around to it.


Discussion:

Resolving patch:
diff --git a/statsmodels/graphics/tsaplots.py b/statsmodels/graphics/tsaplots.py
--- a/statsmodels/graphics/tsaplots.py
+++ b/statsmodels/graphics/tsaplots.py
@@ -57,10 +57,11 @@ def _plot_corr(ax, title, acf_x, confint, lags, irregular, use_vlines,
                         confint[:, 1] - acf_x, alpha=.25)
 
 
-def plot_acf(x, ax=None, lags=None, alpha=.05, use_vlines=True, unbiased=False,
-             fft=False, title='Autocorrelation', zero=True,
-             vlines_kwargs=None, **kwargs):
-    """Plot the autocorrelation function
+def plot_acf(x, ax=None, lags=None, *, alpha=.05, use_vlines=True,
+             unbiased=False, fft=False, missing='none',
+             title='Autocorrelation', zero=True, vlines_kwargs=None, **kwargs):
+    """
+    Plot the autocorrelation function
 
     Plots lags on the horizontal and the correlations on vertical axis.
 
@@ -88,6 +89,9 @@ def plot_acf(x, ax=None, lags=None, alpha=.05, use_vlines=True, unbiased=False,
         If True, then denominators for autocovariance are n-k, otherwise n
     fft : bool, optional
         If True, computes the ACF via FFT.
+    missing : str, optional
+        A string in ['none', 'raise', 'conservative', 'drop'] specifying how
+        the NaNs are to be treated.
     title : str, optional
         Title to place on plot.  Default is 'Autocorrelation'
     zero : bool, optional
@@ -145,12 +149,10 @@ def plot_acf(x, ax=None, lags=None, alpha=.05, use_vlines=True, unbiased=False,
 
     confint = None
     # acf has different return type based on alpha
-    if alpha is None:
-        acf_x = acf(x, nlags=nlags, alpha=alpha, fft=fft,
-                    unbiased=unbiased)
-    else:
-        acf_x, confint = acf(x, nlags=nlags, alpha=alpha, fft=fft,
-                             unbiased=unbiased)
+    acf_x = acf(x, nlags=nlags, alpha=alpha, fft=fft, unbiased=unbiased,
+                missing=missing)
+    if alpha is not None:
+        acf_x, confint = acf_x
 
     _plot_corr(ax, title, acf_x, confint, lags, irregular, use_vlines,
                vlines_kwargs, **kwargs)


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
@@ -138,6 +138,33 @@ def test_plot_acf_kwargs(close_figures):
     assert_(with_vlines != plain)
 
 
+@pytest.mark.matplotlib
+def test_plot_acf_missing(close_figures):
+    # Just test that it runs.
+    fig = plt.figure()
+    ax = fig.add_subplot(111)
+
+    ar = np.r_[1., -0.9]
+    ma = np.r_[1., 0.9]
+    armaprocess = tsp.ArmaProcess(ar, ma)
+    rs = np.random.RandomState(1234)
+    acf = armaprocess.generate_sample(100, distrvs=rs.standard_normal)
+    acf[::13] = np.nan
+
+    buff = BytesIO()
+    plot_acf(acf, ax=ax, missing='drop')
+    fig.savefig(buff, format='rgba')
+    buff.seek(0)
+
+    fig = plt.figure()
+    ax = fig.add_subplot(111)
+    buff_conservative = BytesIO()
+    plot_acf(acf, ax=ax, missing='conservative')
+    fig.savefig(buff_conservative, format='rgba')
+    buff_conservative.seek(0)
+    assert_(buff.read() != buff_conservative.read())
+
+
 @pytest.mark.matplotlib
 def test_plot_pacf_irregular(close_figures):
     # Just test that it runs.