How to return slope from OLS in statsmodels
Asked Answered
F

1

8

I am fitting an OLS model using statsmodels. I need to return the slope of the fitted line.

model = sm.OLS(y, X)
results = model.fit()

results.fittedvalues gives me the points of the line. How to get the slope?

Fennel answered 6/6, 2014 at 17:45 Comment(0)
C
9

results.params contains the "slopes" for all the variables used.

Chiffonier answered 6/6, 2014 at 17:57 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.