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?
OLS or Ordinary Least Squares is a useful method for evaluating a linear regression model. It does this by using specific statistical performance metrics about the model as a whole and each specific parameter of the model. The OLS method comes from the StatsModels python package.
Statsmodels is a Python package that allows users to explore data, estimate statistical models, and perform statistical tests. An extensive list of descriptive statistics, statistical tests, plotting functions, and result statistics are available for different types of data and each estimator.
The prediction interval predicts in what range a future individual observation will fall, while a confidence interval shows the likely range of values associated with some statistical parameter of the data, such as the population mean.
est2.conf_int(alpha=0.05, cols=None)
See also the statsmodels manual.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With