简体   繁体   中英

How to print AIC or BIC from ARIMA Model

I've created an ARIMA model, but I am unable to find a way to print the AIC or BIC results. I need these numbers for model comparison. Unfortunately the documentation on sourceforge is down, and I cannot find my answer when looking at the statsmodel github repository.

Here's my code:

import pandas as pd
import pandas.io.data
import statsmodels.formula.api as sm 
import matplotlib.pyplot as plt 
from statsmodels.tsa.arima_model import ARIMA

list = ['spy']
df = pd.io.data.get_data_yahoo(list, start = '2013-11-01', end = '2016-7-01', interval = 'm')['Adj Close'] 
df.dropna(inplace = True) 
df = df.pct_change()
df.dropna(inplace = True) 

model = ARIMA(df.spy, order = (0,0,1))
results_ARIMA = model.fit(disp=-1)
plt.plot(results_ARIMA.fittedvalues, color='red') 
plt.show() 

I figured out the solution here. You need to import the ARMAResults class from statsmodels.tsa.arima_model.

from statsmodels.tsa.arima_model import ARMAResults 

Once this is complete you can insert

print(ARMAResults.summary(results_ARIMA))

This will print out the results summary which includes the BIC and AIC.

results_ARIMA.aic and results_ARIMA.bic will give you the corresponding values. You don't need the brackets since these are not callable.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM