简体   繁体   English

统计模型的置信区间OLS模型预测

[英]Confidence interval for statsmodels OLS model prediction

I have a very similar problem to this question and it works for the training data. 我有一个与问题非常相似的问题,它适用于训练数据。 Now I´m trying to get the confidence interval for the predicted data: 现在,我正在尝试获取预测数据的置信区间:

from statsmodels.sandbox.regression.predstd import wls_prediction_std
#define y, X, X_forecast as pandas dataframes
regressor = sm.api.OLS(y, X).fit()
wls_prediction_std(regressor.predict(X_forecast))

But, of course, gives an error complaining about regressor.predict being an array. 但是,当然会出现错误,抱怨regressor.predict是一个数组。 How can I calculate the confidence interval for the predicted regression values? 如何计算预测回归值的置信区间?

you may have put the wrong parameter. 您可能输入了错误的参数。

Let's try this one : 让我们试试这个:

wls_prediction_std(regressor, exog=X_forecast, weights=None, alpha=0.05)

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

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