简体   繁体   English

如何从 ARIMA 模型打印 AIC 或 BIC

[英]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.我已经创建了一个 ARIMA 模型,但我找不到打印 AIC 或 BIC 结果的方法。 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.不幸的是,sourceforge 上的文档已关闭,在查看 statsmodel github 存储库时我找不到答案。

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.您需要从 statsmodels.tsa.arima_model 导入 ARMAResults 类。

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.这将打印出包含 BIC 和 AIC 的结果摘要。

results_ARIMA.aic and results_ARIMA.bic will give you the corresponding values. results_ARIMA.aicresults_ARIMA.bic会给你相应的值。 You don't need the brackets since these are not callable.您不需要括号,因为它们不可调用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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