I have time-series sales data. First I group-by the sales by a year. Than I want to forecast the sales for the years 2021,2022 and 2023. I have data from the year 2000.
My question is similar to this one, however I want an answer on how to make forecast outside of the training index.
model = AutoReg(grp, lags=5) model_fit = model.fit() predictions = model_fit.predict(start=len(grp), end=len(grp)+3, dynamic=False)
If I do this the results are:
2021-12-31 NaN 2022-12-31 NaN 2023-12-31 NaN 2024-12-31 NaN
I can make it work if I set the end variable to len(grp)-1, but that means I am making predictions for data inside my sample I want to make predictions for the future.
The attribute dynamic seems salient as it says in the documentation it represents the index at which the predictions use dynamically calculated lag values.
Advertisement
Answer
The index of time-series did not have the freq
set even though the index was annual.
grp.index.freq="Y"
Did the job for me. Also there does not appear to be any problem when you have numeric index of the time-series.