对于ARMA statsmodels确实需要帮助。我尝试使ARMA每次都添加新数据,并使其与最佳值(p,q)(带有最小aic)相匹配,但我总是对此错误感到厌恶:SVD不会收敛
这是我的代码:
series = (df1['BRK-B']-df1['AMT'])
predictions = []
for k in range(3773, 3775):
results = []
for i in range(1, 5):
for j in range(1, 5):
model = statsmodels.tsa.arima_model.ARMA(series[:k], order=(i, j)).fit()
results.append([model.aic, i, j])
df = pd.DataFrame(results)
df.columns = ['aic','p', 'q']
a = df.sort_values(by = 'aic', ascending=True).head(1)
a1 = a.values
b = a1[0].astype(int)
model = statsmodels.tsa.arima_model.ARMA(series[:k], order=(b[1], b[2])).fit()
predictions.append(model.forecast(steps=1)[0][0])
results.clear()
predictions