Skip to content

AttributeError: 'LikelihoodModelResults' object has no attribute 'mle_retvals' #3708

Open

Description

@tgsmith61591

I'm getting an AttributeError while fitting an ARIMA (I'm using version 0.8.0). Here's a (hopefully) reproducible example:

Set up:

import numpy as np
from statsmodels.tsa.arima_model import ARIMA
from numpy.random import RandomState

rs = RandomState(42)
x = rs.rand(25)

Just for your validation, here's x:

>>> x
array([ 0.37454012,  0.95071431,  0.73199394,  0.59865848,  0.15601864,
        0.15599452,  0.05808361,  0.86617615,  0.60111501,  0.70807258,
        0.02058449,  0.96990985,  0.83244264,  0.21233911,  0.18182497,
        0.18340451,  0.30424224,  0.52475643,  0.43194502,  0.29122914,
        0.61185289,  0.13949386,  0.29214465,  0.36636184,  0.45606998])

Fit:

arima = ARIMA(endog=x, order=(0,0,0), exog=None)
res = arima.fit(full_output=0)

And the error:

RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            1     M =           12
 This problem is unconstrained.

At X0         0 variables are exactly at the bounds

At iterate    0    f=  1.44026D-01    |proj g|=  6.38378D-08

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    1      1      4      1     0     0   4.441D-08   1.440D-01
  F =  0.144026168071338

CONVERGENCE: REL_REDUCTION_OF_F_<=_FACTR*EPSMCH

 Cauchy                time 0.000E+00 seconds.
 Subspace minimization time 0.000E+00 seconds.
 Line search           time 0.000E+00 seconds.

 Total User time 0.000E+00 seconds.

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "//anaconda/lib/python2.7/site-packages/statsmodels/tsa/arima_model.py", line 979, in fit
    armafit.mle_retvals = mlefit.mle_retvals
AttributeError: 'LikelihoodModelResults' object has no attribute 'mle_retvals'

Looks like this might be an artifact of not including the full_output (from the LikelihoodModelResults docstring):

full_output : bool, optional
Set to True to have all available output in the Results object's
mle_retvals attribute. The output is dependent on the solver.
See LikelihoodModelResults notes section for more information.

I do not see this error when full_output is truthy.

Activity

  1. josef-pkt commented on May 26, 2017

    @josef-pkt
    Member

    sounds familiar to me, AFAIR full_output=True is required and has never been changed.
    I guess we should initialize the mle_retvals as an empty dict, but then we don't have the converged info, which might cause another exception in summary (set converged=nan?).
    maybe full_output shouldn't be a user option.

    If you want to omit the optimizer output, then I think disp=0 should work. (lbfgs is a bit annoying with the long default print or save)

  2. tgsmith61591 commented on May 26, 2017

    @tgsmith61591
    Author

    disp=0 did the trick (what I originally intended to accomplish with full_output=0, that is). Thanks!

  3. added this to the 0.10 milestone on Jun 25, 2017
  4. josef-pkt commented on Jun 25, 2017

    @josef-pkt
    Member

    We should check if we should make full_output=True as required argument, e.g. ignore user input and warn.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions