Search code examples
pythonstatsmodelsholtwinters

Is statsmodel/exponential smoothing working correctly?


I am performing a time series analysis using statsmodels and the exponential smoothing method. I am trying to reproduce the results from

https://www.statsmodels.org/devel/examples/notebooks/generated/exponential_smoothing.html

with a particular dataframe (with the same format as the example, but only one outcome). Here are the lines of code:

from statsmodels.tsa.api import ExponentialSmoothing, SimpleExpSmoothing, Holt

fit = ExponentialSmoothing(dataframe, seasonal_periods=4, trend='add', seasonal='mul', initialization_method="estimated").fit()
simulations = fit.simulate(5, repetitions=100, error='mul')
fit.fittedvalues.plot(ax=ax, style='--', color='green')
simulations.plot(ax=ax, style='-', alpha=0.05, color='grey', legend=False)
fit.forecast(8).rename('Holt-Winters (add-mul-seasonal)').plot(ax=ax, style='--', marker='o', color='green', legend=True)

However, when I run it, I get the error

TypeError: __init__() got an unexpected keyword argument 'initialization_method'

but when I check the parameters of ExponentialSmoothing in statsmodel, initialization_method is one of them, so I don't know what happens there.

Moving forward, I removed initialization_method from the parameters of ExponentialSmoothing within the code, then I get another error the line below

AttributeError: 'ExponentialSmoothing' object has no attribute 'simulate'

Again, I go and check if simulate is not deprecated in the latest version of statsmodels and no, it is still an attribute.

I upgraded the statsmodels, I upgraded pip and I still get the same errors.

What is it going on there?

Thanks in advance for any help!


Solution

  • Indeed, there was a bug in the previous version, that was corrected in the new version of statsmodels. One only needs to update to statsmodels 0.12.0 and this issue is solved.