在使用ADFfuller后在python中运行Arima

2024-04-26 05:25:47 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个如下的数据集

yearmonth   Count
1/1/2014    104
2/1/2014    47
3/1/2014    83
4/1/2014    72
5/1/2014    101
6/1/2014    135
7/1/2014    75
8/1/2014    83
9/1/2014    86
10/1/2014   78
11/1/2014   24
12/1/2014   24
1/1/2015    87
2/1/2015    33
3/1/2015    49
4/1/2015    79
5/1/2015    110
6/1/2015    104
7/1/2015    105
8/1/2015    100
9/1/2015    79
10/1/2015   72
11/1/2015   104
12/1/2015   26
1/1/2016    127
2/1/2016    50
3/1/2016    96
4/1/2016    87
5/1/2016    127
6/1/2016    102
7/1/2016    78
8/1/2016    99
9/1/2016    52
10/1/2016   103
11/1/2016   53
12/1/2016   30
1/1/2017    150
2/1/2017    57
3/1/2017    81
4/1/2017    61
5/1/2017    85
6/1/2017    103
7/1/2017    77
8/1/2017    45
9/1/2017    47

我想在上面拟合一个时间序列模型。所以我检查了所有4个adf测试选项的平稳性,如下所述

adfuller(var, maxlag=None, regression='c', autolag='AIC', store=False, regresults=False)
adfuller(var, maxlag=None, regression='ct', autolag='AIC', store=False, regresults=False)
adfuller(var, maxlag=None, regression='ctt', autolag='AIC', store=False, regresults=False)
adfuller(var, maxlag=None, regression='nc', autolag='AIC', store=False, regresults=True)

在所有四种情况下,零假设(数据是非平稳的)被拒绝,p值非常小。这意味着我们可以运行一个d=0的arima模型。我也用同样的结论检查了Ljung-Box统计。 现在我想跑了

from statsmodels.tsa.arima_model import ARIMA
model = ARIMA(var, order=(1,0,0))
model_fit = model.fit(disp=0)
print(model_fit.summary())

它给了我以下的错误。我不确定,为什么?你知道吗

raise ValueError("The computed initial AR coefficients are not "

ValueError: The computed initial AR coefficients are not stationary You should induce stationarity, choose a different model order, or you can pass your own start_params. Can somebody please tell me what is happening here?


Tags: 数据store模型nonefalsemodelvaraic