HussainBiedouh HussainBiedouh - 3 years ago 200
Python Question

Reading coef value from OLS regression results

I use pandas and statsmodels to do linear regression. However, i can't find any possible way to read the results. the results are displayed but i need to do some further calculations using coef values. is there any possible way to store coef values into a new variable?

import statsmodels.api as sm
import numpy
ones = numpy.ones(len(x[0]))
t = sm.add_constant(numpy.column_stack((x[0], ones)))
for m in x[1:]:
t = sm.add_constant(numpy.column_stack((m, t)))
results = sm.OLS(y, t).fit()

This is the image of the results

Answer Source

According to the docs, an instance of RegressionResults is returned.

You can see all the available attributes there.

Maybe you are interested in:


The linear coefficients that minimize the least squares criterion. This is usually called Beta for the classical linear model.


model = sm.OLS(Y,X)
results =
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download