I am trying to plot confidence interval band along the predicted values off a SARIMAX model.
A SARIMAX model is fitted using this:
model=sm.tsa.statespace.SARIMAX(data_df['Net Sales'],order=(1, 1, 1),seasonal_order=(1,1,1,12))
results=model.fit()
print(results.summary())
To plot the predicted values I am using the following code:
fig, ax = plt.subplots(figsize=(15,5))
ax.ticklabel_format(useOffset=False, style='plain')
data_df['Net_Sales forecast'] = results.predict(start = 48, end = 60, dynamic= True)
data_df[['Net Sales', 'Net_Sales forecast']].plot(ax=ax, color=['blue', 'orange'], marker='o', legend=True)
I want to plot a confidence interval band of 95% around the forecast data. I have tried various ways but to no avail.
I understand that I can access the parameters for confidence interval in the result of SARIMAX model using the following.
ci = results.conf_int(alpha=0.05)
ci
Returns:
0 1
ar.L1 -3.633910e-01 1.108174e+00
ma.L1 -1.253388e+00 2.229091e-01
ar.S.L12 -3.360182e+00 4.001006e+00
ma.S.L12 -4.078321e+00 3.517885e+00
sigma2 3.080743e+13 3.080743e+13
How do I incorporate this into the plot to show the confidence interval band?