Repository: statsmodels/statsmodels

Issue:
TST failing test_arima111_predict_exog_2127 again and again
latest two travis runs
one failure in python 3.6 and everything others green
one failure in python 2.7 (first test environment) all others green

no failure on appveyor, although that gets often the simulate statespace hang again

either loosen the precision in the test again, or check if the new numbers are not better than the old numbers.
atol=5e-6 is still very tight for numerical integration if there is now more noise in the optimization path

https://travis-ci.org/statsmodels/statsmodels/jobs/283477819
```
>       assert_allclose(predicts, predicts_res, atol=5e-6)
E       AssertionError: 
E       Not equal to tolerance rtol=1e-07, atol=5e-06
E       
E       (mismatch 100.0%)
E        x: array([ 0.025808,  0.023066,  0.024282,  0.02355 ,  0.023794,  0.023592,
E               0.023632,  0.023548,  0.023521,  0.023501,  0.023494])
E        y: array([ 0.025911,  0.023213,  0.024366,  0.023688,  0.023898,  0.02372 ,
E               0.023748,  0.023674,  0.023644,  0.023629,  0.023623])
```

python 3.6:
https://travis-ci.org/statsmodels/statsmodels/jobs/283461477
```
        # regression test, not verified numbers
        # if exog=ue in predict, which values are used ?
        predicts_res = np.array(
              [ 0.02612291,  0.02361929,  0.024966  ,  0.02448193,  0.0248772 ,
                0.0248762 ,  0.02506319,  0.02516542,  0.02531214,  0.02544654,
                0.02559099,  0.02550931])
    
        # if exog=ue[-11:] in predict
        predicts_res = np.array(
              [ 0.02591112,  0.02321336,  0.02436593,  0.02368773,  0.02389767,
                0.02372018,  0.02374833,  0.02367407,  0.0236443 ,  0.02362868,
                0.02362312])
    
>       assert_allclose(predicts, predicts_res, atol=5e-6)
E       AssertionError: 
E       Not equal to tolerance rtol=1e-07, atol=5e-06
E       
E       (mismatch 100.0%)
E        x: array([ 0.025808,  0.023066,  0.024282,  0.02355 ,  0.023794,  0.023592,
E               0.023632,  0.023548,  0.023521,  0.023501,  0.023494])
E        y: array([ 0.025911,  0.023213,  0.024366,  0.023688,  0.023898,  0.02372 ,
E               0.023748,  0.023674,  0.023644,  0.023629,  0.023623])
```


Discussion:

Resolving patch:
diff --git a/statsmodels/base/optimizer.py b/statsmodels/base/optimizer.py
--- a/statsmodels/base/optimizer.py
+++ b/statsmodels/base/optimizer.py
@@ -419,8 +419,10 @@ def _fit_lbfgs(f, score, start_params, fargs, kwargs, disp=True,
         converged = (warnflag == 0)
         gopt = d['grad']
         fcalls = d['funcalls']
+        iterations = d['nit']
         retvals = {'fopt': fopt, 'gopt': gopt, 'fcalls': fcalls,
-                   'warnflag': warnflag, 'converged': converged}
+                   'warnflag': warnflag, 'converged': converged,
+                   'iterations': iterations}
     else:
         xopt = retvals[0]
         retvals = None
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
@@ -820,7 +820,7 @@ def loglike_css(self, params, set_sigma2=True):
         return llf
 
     def fit(self, start_params=None, trend='c', method="css-mle",
-            transparams=True, solver='lbfgs', maxiter=50, full_output=1,
+            transparams=True, solver='lbfgs', maxiter=500, full_output=1,
             disp=5, callback=None, start_ar_lags=None, **kwargs):
         """
         Fits ARMA(p,q) model using exact maximum likelihood via Kalman filter.
@@ -1068,7 +1068,7 @@ def _get_prediction_index(self, start, end, dynamic, index=None):
         return start, end, out_of_sample, prediction_index
 
     def fit(self, start_params=None, trend='c', method="css-mle",
-            transparams=True, solver='lbfgs', maxiter=50, full_output=1,
+            transparams=True, solver='lbfgs', maxiter=500, full_output=1,
             disp=5, callback=None, start_ar_lags=None, **kwargs):
         """
         Fits ARIMA(p,d,q) model by exact maximum likelihood via Kalman filter.


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
@@ -2092,8 +2092,8 @@ def test_arima111_predict_exog_2127():
     # rescaling results in convergence failure
     #model = sm.tsa.ARIMA(np.array(ef)*100, (1,1,1), exog=ue)
     model = ARIMA(ef, (1,1,1), exog=ue)
-    res = model.fit(transparams=False, iprint=0, disp=0)
-
+    res = model.fit(transparams=False, pgtol=1e-8, iprint=0, disp=0)
+    assert_equal(res.mle_retvals['warnflag'],  0)
     predicts = res.predict(start=len(ef), end = len(ef)+10,
                            exog=ue[-11:], typ = 'levels')