I am trying to predict a time series in python statsmodels ARIMA package with the inclusion of an exogenous variable, but cannot figure out the correct way to insert the exogeno
while fiting fit2 you already mentionned exog variables, so no need to repeat it:
exogx = np.array(range(1,5)) # I think you will need 4 exegeneous variables to perform an ARIMAX(0,0,0) since you want out of sample forecast with 4 steps ahead
fit2 = sm.tsa.ARIMA(df, (0,0,0),exog = exogx).fit()
# if you want to do an out-of-sample-forecast use fit2.forecast(steps) instead
#I would do this
pred = fit2.forecast(steps = 4)
fcst_index = pd.date_range(start = df.shift(1,'10T').index[-1] , periods = 4, freq = '10T')
fcst_serie = pd.Series(data = pred1[0], index = fcst_index)
print fcst_serie
Hope that it will help! This is a great post.I have never tried exogeneous variables on ARIMA before but papers are saying it's not really relevant whatever the field you are using it (will search for the papers if needed or you can google it)
history is training array
exog is external variable array
Y_exog_test is out of sample corresponding external variable. Change it to ARIMAX and it should work
model = sm.tsa.statespace.SARIMAX(history, trend='c', order=(1,1,1),seasonal_order=(0,1,0,24),exog=yexog)
model_fit = model.fit()
predicted = model_fit.forecast(step=1,exog=[[Y_exog_test]], dynamic=True)
This is probably better posted on the github issue tracker. I filed a ticket though.
It's best to file a ticket there, if not I might forget it. Quite busy these days.
There was a bug in the logic for the special case of k_ar == 0. Should be fixed. Let me know if you can/cannot give that patch a spin. If not, I can do some more rigorous testing and merge it.
Statsmodels on top of spark? I'm intrigued.