问题
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