ARIMA Models in Python Chapter3
ARIMA Models in Python Chapter3
PACF
A RIMA MODELS IN P YTH ON
James Fulton
Climate informatics researcher
Motivation
...
AR(2) model →
MA(2) model →
# Create figure
fig, (ax1, ax2) = plt.subplots(2,1, figsize=(8,8))
plt.show()
James Fulton
Climate informatics researcher
AIC - Akaike information criterion
Lower AIC indicates a better model
# Fit model
results = model.fit()
AIC: 2806.36
BIC: 2821.09
0 0 2900.13 2905.04
0 1 2828.70 2838.52
0 2 2806.69 2821.42
1 0 2810.25 2820.06
1 1 2806.37 2821.09
1 2 2807.52 2827.15
...
# Fit model
model = SARIMAX(df, order=(p,0,q))
results = model.fit()
try:
# Fit model
model = SARIMAX(df, order=(p,0,q))
results = model.fit()
except:
# Print AIC and BIC as None when fails
print(p, q, None, None)
James Fulton
Climate informatics researcher
Introduction to model diagnostics
How good is the nal model?
2013-01-23 1.013129
2013-01-24 0.114055
2013-01-25 0.430698
2013-01-26 -1.247046
2013-01-27 -0.499565
... ...
mae = np.mean(np.abs(residuals))
...
===================================================================================
Ljung-Box (Q): 32.10 Jarque-Bera (JB): 0.02
Prob(Q): 0.81 Prob(JB): 0.99
Heteroskedasticity (H): 1.28 Skew: -0.02
Prob(H) (two-sided): 0.21 Kurtosis: 2.98
===================================================================================
James Fulton
Climate informatics researcher
The Box-Jenkins method
From raw data → production model
identi cation
estimation
model diagnostics
Plot ACF/PACF
plot_acf() , plot_pacf()
results.summary()