Python ARIMA exogenous variable out of sample

后端 未结 3 2154
广开言路
广开言路 2021-02-14 13:04

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

3条回答
  •  谎友^
    谎友^ (楼主)
    2021-02-14 13:33

    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)

提交回复
热议问题