How to ignore statsmodels Maximum Likelihood convergence warning?
Asked Answered
L

3

19

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.

Lucubrate answered 23/12, 2015 at 22:20 Comment(2)
see for example #15934241 either filter the warnings, or better use catch_warnings to disable them only locally. ConvergenceWarning is defined by statsmodels.Talapoin
@user333700 thank you! What if I just want to ignore the warning?Lucubrate
F
20

To specifically ignore ConvergenceWarnings:

import warnings
from statsmodels.tools.sm_exceptions import ConvergenceWarning
warnings.simplefilter('ignore', ConvergenceWarning)
Flaherty answered 3/5, 2020 at 17:49 Comment(0)
B
12

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)
Bathymetry answered 30/3, 2016 at 13:15 Comment(0)
L
5

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})
Lordosis answered 12/7, 2021 at 18:0 Comment(1)
does not work for me, still prints warningsBadinage

© 2022 - 2024 — McMap. All rights reserved.