RaChelVH
RaChelVH

Reputation: 31

No result for SARIMAX

I'm working on a project to analyse how covid 19 affects shipment volume and I'm using SARIMAX to predict the shipment volume for the next few months. However, I keep getting the results as shown below :

   # Shipment volume data (monthly basis)
  
    df_monthly = df.loc[:'2020-06-30'].resample('MS').sum()
    df_monthly


   # covid 19 data (monthly basis)
     
     df_covid_monthly = df_covid.loc[:'2020-06-30']
     df_covid_monthly = df_covid.resample('MS').sum() 
     df_covid_monthly 

  
   # SARIMAX model
     
     model= SARIMAX(df_monthly, exog=df_covid_new, order=(2,1,1), enforce_invertibility=False, 
           enforce_stationarity=False)

     results= model.fit()

    # Prediction

    pred =  results.get_prediction(start='2020-06-01',end='2020-12-01',dynamic=False, index=None, 
    exog=df_covid_monthly['2020-02-01':], 
     extend_model=None, extend_kwargs=None)
    pred 

output :

<statsmodels.tsa.statespace.mlemodel.PredictionResultsWrapper at 0x27b64b4a608> 

Upvotes: 2

Views: 1300

Answers (2)

RaChelVH
RaChelVH

Reputation: 31

After many readings and attempts on modifying my codes, I'm finally able to get the result for my prediction. Here's the changes I made:
model = sm.tsa.SARIMAX(endog=df_monthly, order=(1,1,1),seasonal_order=(0,1,1,12))

model_fit = model.fit()

prediction = model_fit.predict(start='2020-07-01',end='2020-1201',dynamic=False, exog=df_covid_monthly,extend_kwargs=None)

Upvotes: 1

Kevin S
Kevin S

Reputation: 2803

This is the expected output. You need to access properties off of PredictionResultsWrapper such as predicted_mean.

See the development documentation: https://www.statsmodels.org/devel/generated/statsmodels.tsa.base.prediction.PredictionResults.html

Note that you won't see the Wrapper since this is just a class that attaches indices and does housekeeping. PredictionResults is the main class returned.

Upvotes: 1

Related Questions