Let's look at how to optimize the parameters of the models.
import statsmodels.tsa.api as smtsa aic=[] for ari in range(1, 3): obj_arima = smtsa.ARIMA(ts_log_diff, order=(ari,2,0)).fit(maxlag=30, method='mle', trend='nc') aic.append([ari,2,0, obj_arima.aic]) print(aic)
[[1, 2, 0, -76.46506473849644], [2, 2, 0, -116.1112196485397]]
Therefore, our model parameters are p=2
, d=2
, and q=0
in this scenario for the AR model, as the AIC for this combination is the least.
Even for the ARIMA model, we can optimize the parameters by using the following code:
import statsmodels.tsa.api as smtsa
aic=[]
for ari in range(1, 3):
for maj in range(1,3):
arima_obj = smtsa.ARIMA(ts_log, order=(ari,1,maj)).fit(maxlag=30, method='mle', trend='nc')
aic.append([ari,1, maj, arima_obj.aic])
print(aic)
The following is the output you get by executing the preceding code:
[[1, 1, 1, -242.6262079840165], [1, 1, 2, -248.8648292320533], [2, 1, 1, -251...