kevin
kevin

Reputation: 2014

Python Statsmodels - AttributeError: 'ARMAResults' object has no attribute 'plot_predict'

I am trying to run the following Statsmodels example from http://statsmodels.sourceforge.net/devel/examples/notebooks/generated/tsa_arma_0.html.

fig, ax = plt.subplots(figsize=(12, 8))
ax = dta.ix['1950':].plot(ax=ax)
fig = arma_mod30.plot_predict('1990', '2012', dynamic=True, ax=ax, plot_insample=False)

Running the code above gives the error message below. Even after upgrading to Statsmodels 6, I am getting the same error.

    AttributeError                            Traceback (most recent call last)
    <ipython-input-69-2a5da9c756f0> in <module>()
          1 fig, ax = plt.subplots(figsize=(12, 8))
          2 ax = dta.ix['1950':].plot(ax=ax)
    ----> 3 fig = arma_mod30.plot_predict('1990', '2012', dynamic=True, ax=ax,         plot_insample=False)

C:\Anaconda\lib\site-packages\statsmodels\base\wrapper.pyc in __getattribute__(self, attr)
     33             pass
     34 
---> 35         obj = getattr(results, attr)
     36         data = results.model.data
     37         how = self._wrap_attrs.get(attr)

AttributeError: 'ARMAResults' object has no attribute 'plot_predict'

Any suggestions?

This issue has been resolved after following the below comment. Thanks.

Upvotes: 4

Views: 26037

Answers (3)

virgesmith
virgesmith

Reputation: 822

I've just encountered the same issue with statsmodels 0.13.2. After a bit of digging in their release notes I can see that the plotting functionality has been separated out. Instead of

arma_mod30.plot_predict(...)

try

from statsmodels.graphics.tsaplots import plot_predict


plot_predict(arma_mod30, ...)

Hope this helps

Upvotes: 4

Juh&#225;sz Tomi
Juh&#225;sz Tomi

Reputation: 21

I also meet this issue for me the #pip install statsmodels==0.11.0 version get solved this promblem. I get this error after updating all the python packages. GL

Upvotes: 2

GoingMyWay
GoingMyWay

Reputation: 17468

Maybe it is the version of statsmodels made that happen. Try to check the version of statsmodels before upgrade the package to 0.6.1

 >>> import statsmodels
 >>> statsmodels.__version__

 $ pip install statsmodels --upgrade

For more information, click this issue on statsmodels.github

Upvotes: 1

Related Questions