简体   繁体   English

Python - StatsModels,OLS置信区间

[英]Python - StatsModels, OLS Confidence interval

In Statsmodels I can fit my model using 在Statsmodels中,我可以使用我的模型

import statsmodels.api as sm

X = np.array([22000, 13400, 47600, 7400, 12000, 32000, 28000, 31000, 69000, 48600])
y = np.array([0.62, 0.24, 0.89, 0.11, 0.18, 0.75, 0.54, 0.61, 0.92, 0.88])
X2 = sm.add_constant(X)
est = sm.OLS(y, X2)
est2 = est.fit()

then print a nice summary using 然后使用打印一个很好的摘要

print(est2.summary())

and the extract things like the p-values using 并使用提取的东西,如p值

est2.pvalues

which can be found on this page http://www.statsmodels.org/dev/generated/statsmodels.regression.linear_model.RegressionResults.html 可在此页面找到http://www.statsmodels.org/dev/generated/statsmodels.regression.linear_model.RegressionResults.html

but in the summary there are confidence intervals and I am lost as to how to extract these confidence intervals, like I do with the pvalues. 但是在摘要中存在置信区间,我对如何提取这些置信区间感到迷茫,就像我对pvalues一样。

Apart from seeing them in the summary, how can i get these confidence intervals? 除了在摘要中看到它们,我怎样才能获得这些置信区间?

est2.conf_int(alpha=0.05, cols=None)

另请参见statsmodels手册

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

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