ARIMA 模型的不可逆
non Invertible of a ARIMA model
我正在尝试编写代码来生成一系列 arima 模型并比较不同 models.The 代码如下。
p=0
q=0
d=0
pdq=[]
aic=[]
for p in range(6):
for d in range(2):
for q in range(4):
arima_mod=sm.tsa.ARIMA(df,(p,d,q)).fit(transparams=True)
x=arima_mod.aic
x1= p,d,q
print (x1,x)
aic.append(x)
pdq.append(x1)
keys = pdq
values = aic
d = dict(zip(keys, values))
print (d)
minaic=min(d, key=d.get)
for i in range(3):
p=minaic[0]
d=minaic[1]
q=minaic[2]
print (p,d,q)
其中'df'是时间序列data.And输出如下,
(0, 0, 0) 1712.55522759
(0, 0, 1) 1693.436483044094
(0, 0, 2) 1695.2226857997066
(0, 0, 3) 1690.9437925956158
(0, 1, 0) 1712.74161799
(0, 1, 1) 1693.0408994539348
(0, 1, 2) 1677.2235087182808
(0, 1, 3) 1679.209810237856
(1, 0, 0) 1700.0762847127553
(1, 0, 1) 1695.353190569905
(1, 0, 2) 1694.7907607467605
(1, 0, 3) 1692.235442716487
(1, 1, 0) 1714.5088374907164
ValueError: The computed initial MA coefficients are not invertible
You should induce invertibility, choose a different model order, or you can
pass your own start_params.
即对于顺序 (1,1,1),模型是不可逆的。所以过程停止 there.How 我可以跳过 p、d、q 的这种不可逆组合并继续其他组合吗
使用try: ... except: ...
捕获异常并继续
for p in range(6):
for d in range(2):
for q in range(4):
try:
arima_mod=sm.tsa.ARIMA(df,(p,d,q)).fit(transparams=True)
x=arima_mod.aic
x1= p,d,q
print (x1,x)
aic.append(x)
pdq.append(x1)
except:
pass
# ignore the error and go on
我正在尝试编写代码来生成一系列 arima 模型并比较不同 models.The 代码如下。
p=0
q=0
d=0
pdq=[]
aic=[]
for p in range(6):
for d in range(2):
for q in range(4):
arima_mod=sm.tsa.ARIMA(df,(p,d,q)).fit(transparams=True)
x=arima_mod.aic
x1= p,d,q
print (x1,x)
aic.append(x)
pdq.append(x1)
keys = pdq
values = aic
d = dict(zip(keys, values))
print (d)
minaic=min(d, key=d.get)
for i in range(3):
p=minaic[0]
d=minaic[1]
q=minaic[2]
print (p,d,q)
其中'df'是时间序列data.And输出如下,
(0, 0, 0) 1712.55522759
(0, 0, 1) 1693.436483044094
(0, 0, 2) 1695.2226857997066
(0, 0, 3) 1690.9437925956158
(0, 1, 0) 1712.74161799
(0, 1, 1) 1693.0408994539348
(0, 1, 2) 1677.2235087182808
(0, 1, 3) 1679.209810237856
(1, 0, 0) 1700.0762847127553
(1, 0, 1) 1695.353190569905
(1, 0, 2) 1694.7907607467605
(1, 0, 3) 1692.235442716487
(1, 1, 0) 1714.5088374907164
ValueError: The computed initial MA coefficients are not invertible
You should induce invertibility, choose a different model order, or you can
pass your own start_params.
即对于顺序 (1,1,1),模型是不可逆的。所以过程停止 there.How 我可以跳过 p、d、q 的这种不可逆组合并继续其他组合吗
使用try: ... except: ...
捕获异常并继续
for p in range(6):
for d in range(2):
for q in range(4):
try:
arima_mod=sm.tsa.ARIMA(df,(p,d,q)).fit(transparams=True)
x=arima_mod.aic
x1= p,d,q
print (x1,x)
aic.append(x)
pdq.append(x1)
except:
pass
# ignore the error and go on