python ValueError: Start must be in dates. Got 2016-01-01 | 2016-01-01 00:00:00
Asked Answered
D

3

8

I am using statsmodels.tsa.statespace.sarimax to make prediction. Here is my code

pprint(list(rolmean_df.index)[0])
>> datetime.date(2015, 5, 19)

mod = sm.tsa.statespace.SARIMAX(rolmean_df['IC_10_diff'], trend='n', order=(2,1,2))
results = mod.fit()
s = results.get_prediction(start = pd.to_datetime('2016-01-01').date(), dynamic= False)
>> ValueError: Start must be in dates. Got 2016-01-01 | 2016-01-01 00:00:00

I am not sure whether my "start" format is wrong or something else does not work.

Dicephalous answered 17/5, 2017 at 18:21 Comment(3)
looks like what you need is a datetime for start not a date try results.get_prediction(start = pd.to_datetime('2016-01-01'), dynamic= False)Namtar
I tried it but get a similar result:ValueError: Start must be in dates. Got 2016-01-01 00:00:00 | 2016-01-01 00:00:00Dicephalous
have you solved it?Thanatos
D
10

From the doc: http://www.statsmodels.org/dev/generated/statsmodels.tsa.statespace.sarimax.SARIMAXResults.html

  • get_forecast([steps]) Out-of-sample forecasts
  • get_prediction([start, end, dynamic, exog]) In-sample prediction and out-of-sample forecasting

so, "Start must be in dates" means start should be in your data set.

If you want to use the model to forecase , use get_forecast().

Diomedes answered 25/5, 2017 at 8:22 Comment(0)
C
2

I had a similar problem. You have to make sure that the start date is contained within rolmean_df['IC_10_diff'].

Just print all the values in `rolmean_df['IC_10_diff']' and pick the closest one to 2016-01-01.

Chetchetah answered 17/4, 2018 at 7:47 Comment(0)
K
1

I have the same problem with you some days ago, Now I have a reasonable explanation.

I think that the start date and the end date of this function are depending on your data set.

For example, for the first time I want to make the start date equal to '2017-10-01',but this date is not contained by my data. And then '2017-12-01' is value of the start date, the file could be compiled,because this date is in my dataset.

Kling answered 11/3, 2018 at 11:53 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.