Reputation: 287
Lets say I need to forecast the TPV/sales per month which would be affected by Black Friday, Cyber Monday, Christmas and other campaigns.. I add in all these 4 variables in the dataframe and include it in 'exog' like below
mod = sm.tsa.statespace.SARIMAX(Y,order=param,seasonal_order=param_seasonal,exog=exog_var,enforce_stationarity=False,enforce_invertibility=False)
My question is How do we add the values for these 4 exog variables for future dates?? If I add these 4 variables and leave the 'TPV/sales' column blank.. It does not predict for those time periods and output 'nan'
Please help me understand how to add exog variables for future dates and how to forecast the Y variable?
Upvotes: 0
Views: 8346
Reputation: 3195
The way statsmodels structures analysis is in the following steps:
Create a model to describe your data, e.g.:
mod = sm.tsa.SARIMAX(endog_training, order=(1, 0, 0), exog=exog_training)
Fit the parameters of your model, e.g.:
res = mod.fit()
Perform post-estimation analysis.
a. For example, you might want to examine the fitted parameters, summary output, etc, e.g.:
print(res.summary())
b. Or, as in your case, you might want to perform out-of-sample forecasting, e.g.:
forecast = res.forecast(nsteps, exog=exog_test)
So you only want to include your training data in the model construction step. When you want to forecast new periods with the out-of-sample exog
values, you do that using the forecast
method of the results object.
Upvotes: 2