我正在尝试使用statsmodels.tsa.statespace.sarimax.SARIMAX
对于某些数据SARIMAX返回错误
LinAlgError: Non-positive-definite forecast error covariance matrix encountered at period 0
#Kd forecast
ps = range(0, 13)
ds = range(0, 3)
qs = range(0, 13)
parameters = product(ps, ds, qs)
parameters_list = list(parameters)
len(parameters_list)
results = []
best_aic = float("inf")
warnings.filterwarnings('ignore')
for param in parameters_list:
try:
model_Kd=sm.tsa.statespace.SARIMAX(stock1.Kd, order=(param[0], param[1], param[2]), seasonal_order=(0, 0, 0, 0)).fit(disp=-1)
except ValueError:
print('wrong parameters:', param)
continue
aic = model_Kd.aic
#save best model, aic, parameters
if abs(aic) < abs(best_aic):
best_model_Kd = model_Kd
best_aic = aic
best_param = param
results.append([param, model_Kd.aic])
warnings.filterwarnings('default')
result_table = pd.DataFrame(results)
result_table.columns = ['parameters', 'aic']
print(result_table.sort_values(by = 'aic', ascending=True).head())
对于某些数据集,由于非正定预测误差协方差矩阵,我无法应用SARIMAX。我想了解为什么会发生错误以及如何处理错误。
我的数据集
0.14294117647058824
0.09346153846153847
0.10565217391304349
0.11619047619047619
0.1525
0.10708333333333332
0.2064
0.15636363636363637
0.14181818181818182
0.1688888888888889
0.1919191919191919
0.17721518987341772
0.3137254901960784
0.1978021978021978
0.17647058823529413
0.13333333333333333
0.5365853658536586
0.0782312925170068
0.08
0.08421052631578947
0.16049382716049382
0.29605263157894735
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0