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
ones = numpy.ones(len(x))
t = sm.add_constant(numpy.column_stack((x, ones)))
for m in x[1:]:
t = sm.add_constant(numpy.column_stack((m, t)))
results = sm.OLS(y, t).fit()
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 = model.fit() print(results.params)