Repository: statsmodels/statsmodels

Issue:
Pickling ARIMA fails
ARIMA class includes dates in `__getnewargs__` method. but model do not includes dates . my version is  '0.8.0'.

```code.py
from statsmodels.compat.python import cPickle

cPickle.dumps(arima_mod)
# => AttributeError: 'ARIMA' object has no attribute 'dates'

type(arima_mod)
# => statsmodels.tsa.arima_model.ARIMA
```

```arima_model.py
    def __getnewargs__(self):
        return ((self.endog),
                (self.k_lags, self.k_diff, self.k_ma),
                self.exog, self.dates, self.freq, self.missing)
```

test code mod is actually ARMA model. at statsmodels/tsa/tests/test_arima.py.

```
def test_arima_pickle():
    endog = y_arma[:, 6]
    mod = ARIMA(endog, (1, 0, 1)
```



Discussion:
Sorry, I'm slow in catching up with issues that are not on my current topic list.

to clarify the issue

if we use ARIMA(1, 1, 1) in test_arima_pickle, then it raises an error about missing dates

```
======================================================================
ERROR: statsmodels.tsa.tests.test_arima.test_arima_pickle
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Users\josef\Downloads\WinPython-64bit-3.4.4.5Qt5\python-3.4.4.amd64\l
ib\site-packages\nose\case.py", line 198, in runTest
    self.test(*self.arg)
  File "E:\Josef_new\eclipsews\statsmodels_py34_pr\statsmodels\tsa\tests\test_ar
ima.py", line 2276, in test_arima_pickle
    pkl_mod = cPickle.loads(cPickle.dumps(mod))
  File "E:\Josef_new\eclipsews\statsmodels_py34_pr\statsmodels\tsa\arima_model.p
y", line 994, in __getnewargs__
    self.exog, self.dates, self.freq, self.missing)
AttributeError: 'ARIMA' object has no attribute 'dates'
```


using the debugger, in the test example the other keywords are also not available except for exog

```
(Pdb) self.dates
*** AttributeError: 'ARIMA' object has no attribute 'dates'
(Pdb) self.freq
*** AttributeError: 'ARIMA' object has no attribute 'freq'
(Pdb) self.exog
(Pdb) self.missing
*** AttributeError: 'ARIMA' object has no attribute 'missing'
```

Resolving patch:
diff --git a/statsmodels/tsa/arima_model.py b/statsmodels/tsa/arima_model.py
--- a/statsmodels/tsa/arima_model.py
+++ b/statsmodels/tsa/arima_model.py
@@ -989,9 +989,13 @@ def __new__(cls, endog, order, exog=None, dates=None, freq=None,
             return mod
 
     def __getnewargs__(self):
+        # using same defaults as in __init__
+        dates = getattr(self, 'dates', None)
+        freq = getattr(self, 'freq', None)
+        missing = getattr(self, 'missing', 'none')
         return ((self.endog),
                 (self.k_lags, self.k_diff, self.k_ma),
-                self.exog, self.dates, self.freq, self.missing)
+                self.exog, dates, freq, missing)
 
     def __init__(self, endog, order, exog=None, dates=None, freq=None,
                  missing='none'):


Test patch:
diff --git a/statsmodels/tsa/tests/test_arima.py b/statsmodels/tsa/tests/test_arima.py
--- a/statsmodels/tsa/tests/test_arima.py
+++ b/statsmodels/tsa/tests/test_arima.py
@@ -2272,7 +2272,7 @@ def test_arma_pickle():
 
 def test_arima_pickle():
     endog = y_arma[:, 6]
-    mod = ARIMA(endog, (1, 0, 1))
+    mod = ARIMA(endog, (1, 1, 1))
     pkl_mod = cPickle.loads(cPickle.dumps(mod))
 
     res = mod.fit(trend="c", disp=-1)