Statsmodels ETSModel get_prediction encounters error

616 views Asked by At

I am attempting to obtain the prediction intervals from a Holt Winters time series model through StatsModels ETSModel. Can someone help me figure out what is going wrong?

fit1 = ETSModel(x_train, seasonal_periods=7, trend='add', seasonal='mul', damped_trend=True).fit()
fcst = fit1.get_prediction(start=current_date, end=current_date + np.timedelta64(6,'D'))

I get the following error:

File "C:\ProgramData\Anaconda3\lib\site-packages\statsmodels\tsa\exponential_smoothing\ets.py", line 2078, in get_prediction
    **simulate_kwargs,

  File "C:\ProgramData\Anaconda3\lib\site-packages\statsmodels\tsa\exponential_smoothing\ets.py", line 2234, in __init__
    start : (end + 1)

ValueError: could not broadcast input array from shape (0) into shape (7)

This is the input:

x_train
Out[24]: 
ds
2020-08-04    1027.0
2020-08-05    1813.0
2020-08-06    2157.0
2020-08-07    3070.0
2020-08-08    2968.0
2020-08-09    2083.0
2020-08-10    1762.0
2020-08-11    1755.0
2020-08-12    1788.0
2020-08-13    2266.0
2020-08-14    3272.0
2020-08-15    2768.0
2020-08-16    1869.0
2020-08-17    1940.0
2020-08-18    1673.0
2020-08-19    1821.0
2020-08-20    2293.0
2020-08-21    2802.0
2020-08-22    2604.0
2020-08-23    1843.0
2020-08-24    1758.0
2020-08-25    1393.0
2020-08-26    1612.0
2020-08-27    2165.0
2020-08-28    2898.0
2020-08-29    2471.0
2020-08-30    2297.0
Freq: D, dtype: float64

current_date
Out[25]: numpy.datetime64('2020-09-01')
1

There are 1 answers

1
cfulton On BEST ANSWER

This looks like a bug with get_prediction if the start date is after the end of the dataset. I suggest you file a bug report at https://github.com/statsmodels/statsmodels/issues/new?template=bug_report.md.

In the meantime, it looks like you will need to set start equal to the last date in your dataset (e.g. 2020-08-30, in the example you gave) and then manually subset the results to only be from current_date forwards.