I'm trying to use SARIMAX
to extend a 34-element monthly time series to 35 elements, assuming a 12-month seasonal component.
However, the predict
method fails with the traceback:
<ipython-input-40-151295bf5e3e> in approach_4_stationarity(data_file_name)
27 sarima = SARIMAX( total_items_array, order = ( 1, 0, 0 ), seasonal_order = (0,0,0,12) )
28 sarima.fit()
---> 29 next_month_item_cnt = sarima.predict( (1, 0, 0 ), start = 34, end = 34 )
30 print( "next_month_item_cnt", next_month_item_cnt, file = sys.stderr )
31 total_items_array = total_items_array.append( next_month_item_cnt )
/opt/conda/lib/python3.6/site-packages/statsmodels/base/model.py in predict(self, params, exog, *args, **kwargs)
205 This is a placeholder intended to be overwritten by individual models.
206 """
--> 207 raise NotImplementedError
208
209
How can I fix this?
The fit
method does not affect the model object, it returns a new results object. You probably want something like the following:
model = SARIMAX(total_items_array, order=(1, 0, 0), seasonal_order=(0,0,0,12))
results = model.fit()
next_month_item_cnt = results.forecast(steps=1)