HussainBiedouh - 3 years ago 200

Python Question

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()

Recommended for you: Get network issues from **WhatsUp Gold**. **Not end users.**

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:

params

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

Example:

```
model = sm.OLS(Y,X)
results = model.fit()
print(results.params)
```

Recommended from our users: **Dynamic Network Monitoring from WhatsUp Gold from IPSwitch**. ** Free Download**