python - 无法理解和使用 Statsmodels 的 SARIMAX `conf_int()` 输出

标签 python forecasting statsmodels

我一直在尝试使用 statsmodels 的 SARIMAX 模型,但返回了我的预测的置信区间。

我的目标是生成置信区间上限和下限的一系列预测。

我尝试拟合我的模型,然后使用 get_prediction(),最后使用 conf_int()get_prediction() 按预期返回每个索引的数据。然而,conf_int() 返回一个奇怪的矩阵:

        0   1
ar.S.L7 0.018806    0.194818
ma.S.L7 -0.830238   -0.717128
sigma2  40.832875   48.105937

我不明白。我注意到这些是模型的参数,但我不知道如何使用它们来获得每个指数的上限和下限预测。

我咨询过:this , this ,和this ,但他们似乎都没有同样的问题。我也看过this question 。我尝试尽可能严格地遵循他们的代码,但无法重现问题。

最佳答案

当你这样做时:

model = sm.tsa.statespace.SARIMAX(params)
fit_model = model.fit()

nforecast = 144
forecast = fit_model.get_prediction(end=model.nobs+nforecast)

ci = forecast.conf_int()

print(ci.head())

你应该得到:

          upper [name of your feature]     lower [name of your feature]

 time1           0.018806                    0.194818 
 time2          -0.830238                   -0.717128
 time3           40.832875                   48.105937

如果原始数据中没有特征标题,则 ci 的默认标题只是“上”和“下”。

关于python - 无法理解和使用 Statsmodels 的 SARIMAX `conf_int()` 输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41421572/

相关文章:

php - Perl 与 PHP 的网络抓取

python - 允许使用 xmlrpc 在字符串中传输任何 ASCII 字符

python - 如何在 python 中打开终端并运行命令?

.net - .NET 开发的 future : ASP. NET 还是 WPF/Silverlight/Winforms?

python - AR 样本外预测 Python Statsmodels

python - 由于 scipy 导入错误,无法导入 statsmodels.api

python - 有没有办法可以使用用户输入批量重命名文件夹中的文件?

r - 预测将 forecast.gts 中的 xreg 参数与每个时间序列具有不同值的多个外部变量一起使用(hts 包)

python - 如何获得指数和 Gamma 分布的对数似然

python - 使用 ols().fit() 使用 statsmodels.api 时出错