16

I was trying to find the optimal parameter order by using a loop:

d = 1    
for p in range(3):
    for q in range(3):
        try:
           order = (p, 0, q)
           params = (p, d, q)
           arima_mod = ARIMA(ts.dropna(), order).fit(method = 'css-mle', disp = 0)
                arima_mod_aics[params] = arima_mod.aic
            except:
                pass

and I have received the message:

/usr/local/lib/python2.7/dist-packages/statsmodels-0.6.1-py2.7-linux-x86_64.egg/statsmodels/base/model.py:466: ConvergenceWarning: Maximum Likelihood optimization failed to converge. Check mle_retvals
"Check mle_retvals", ConvergenceWarning)

I would like to ignore this warning, what should I do? Any suggestion?

Thanks in advance.

tmthydvnprt
  • 10,398
  • 8
  • 52
  • 72
Jellomima
  • 183
  • 1
  • 1
  • 7
  • see for example http://stackoverflow.com/questions/15933741/how-do-i-catch-a-numpy-warning-like-its-an-exception-not-just-for-testing either filter the warnings, or better use catch_warnings to disable them only locally. ConvergenceWarning is defined by statsmodels. – Josef Dec 24 '15 at 00:12
  • @user333700 thank you! What if I just want to ignore the warning? – Jellomima Dec 26 '15 at 04:17

3 Answers3

15

To specifically ignore ConvergenceWarnings:

import warnings
from statsmodels.tools.sm_exceptions import ConvergenceWarning
warnings.simplefilter('ignore', ConvergenceWarning)
1''
  • 26,823
  • 32
  • 143
  • 200
11

See this example from the statsmodels sourceforge, especially In [17]:.

import warnings

with warnings.catch_warnings():
    warnings.filterwarnings("ignore")
    # Line that is not converging
    likev = mdf.profile_re(0, dist_low=0.1, dist_high=0.1)
tmthydvnprt
  • 10,398
  • 8
  • 52
  • 72
3

A clean way to do it is to use the included warn_convergence. You can pass it to fit method like so:

arima.fit(method_kwargs={"warn_convergence": False})
ItCantBe
  • 31
  • 1