Python - StatsModels, OLS Confidence interval

我与影子孤独终老i 提交于 2019-12-21 12:12:41

问题


In Statsmodels I can fit my model using

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

est2.pvalues

which can be found on this page 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.

Apart from seeing them in the summary, how can i get these confidence intervals?


回答1:


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

See also the statsmodels manual.



来源:https://stackoverflow.com/questions/44302099/python-statsmodels-ols-confidence-interval

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!