I am trying to implement a time series forecast and followed the helpful tutorial as found here : https://www.analyticsvidhya.com/blog/2016/02/time-series-forecasting-codes-python/
A sample of my time series object, after log transformations and so on can be found below:
ts =
2015-02-01 4.532599
2015-03-01 7.635787
2015-04-01 7.698029
2015-05-01 4.564348
2015-06-01 4.744932
2015-09-01 5.365976
2015-10-01 7.657283
2016-02-01 7.059618
2016-03-01 5.433722
2016-04-01 7.600902
When I get at the point to try and fir the AR model, i.e.
model = ARIMA(ts_log, order=(1, 1, 0))
results_AR = model.fit(disp=-1)
plt.plot(ts_log)
plt.plot(results_AR.fittedvalues, color='red')
plt.title('RSS: %.4f'% sum((results_AR.fittedvalues-ts_log_diff)**2))
plt.show()
My issue is when I try to do so I get:
TypeError: ufunc 'add' did not contain a loop with signature matching types dtype('<U21') dtype('<U21') dtype('<U21')
When I print out the type of data in my time series index I get:
DatetimeIndex(['2015-05-01'], dtype='datetime64[ns]', freq=None)
Then I tried adding the date parameter in ARIMA() like this:
model = ARIMA(dt_ts, order=(1, 1, 0), dates=dt_ts.index.values)
or by adding a separate array that has all my dates called formatted:
model = ARIMA(dt_ts, order=(1, 1, 0), dates=formatted)
And in both cases I got this:
ValueError: Given a pandas object and the index does not contain dates
Anyone has an idea why this happens and how I can fix it?
Thanks in advance.