简体   繁体   English

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

[英]Trouble understanding and using Statsmodels' SARIMAX `conf_int()` output

I've been trying to use statsmodels' SARIMAX model but return a confidence interval around my predictions. 我一直在尝试使用statsmodels的SARIMAX模型,但是返回围绕我的预测的置信区间。

My goal is to generate series of predictions for the upper and lower bounds of the confidence interval. 我的目标是针对置信区间的上限和下限生成一系列预测。

I attempted to fit my model, then use get_prediction() , and finally conf_int() . 我试图拟合我的模型,然后使用get_prediction() ,最后使用conf_int() get_prediction() returns data for each of my index as I expected. get_prediction()按预期返回每个索引的数据。 However, conf_int() returns a strange matrix: 但是, conf_int()返回一个奇怪的矩阵:

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

that I don't understand. 我不明白 I noticed that these are the parameters for a model, but I don't know how to use these to get upper and lower predictions for each of my indices. 我注意到这些是模型的参数,但是我不知道如何使用这些参数来获取我的每个指数的上,下预测。

I've consulted: this , this , and this , but none of them seem to have the same problem. 我已经咨询过: thisthisthis ,但是它们似乎都没有相同的问题。 I've also looked over this question . 我也研究了这个问题 I have attempted to follow their code as closely as possible, but can't recreate the problem. 我试图尽可能地遵循他们的代码,但是无法重现该问题。

When you do : 当您这样做时:

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())

You should get: 您应该得到:

          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

the default headings of ci is just 'upper' and 'lower' if you don't have features headings in your original data. 如果原始数据中没有功能标题,则ci的默认标题仅为“上”和“下”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM