I have a statsmodels.discrete.discrete_model.BinaryResultsWrapper
that was the output of running statsmodels.api.Logit(...).fit()
. I can call the .summary()
method which prints a table of results with the coefficients embedded in text, but what I really need is to store those coefficients into a variable for later use. How can I do this? The documentation is not really clear on how to do this very basic operation (probably the most basic thing anyone would want to do with the results, besides print them)
When I try the fittedvalues() method, which looked like it would return the coefficients, I just get the error:
'Series' object is not callable
For a sample of size n, the likelihood for a binary logistic regression is given by: L(β;y,X)=n∏i=1πyii(1−πi)1−yi=n∏i=1(exp(Xiβ)1+exp(Xiβ))yi(11+exp(Xiβ))1−yi.
Logistic regression coefficients also correspond to marginal effects, but the unit of measurement is not test points or whatever; instead, the unit of measurement is log odds, and and a 1-point increase in log odds is difficult to put in context.
The logistic regression coefficient β associated with a predictor X is the expected change in log odds of having the outcome per unit change in X. So increasing the predictor by 1 unit (or going from 1 level to the next) multiplies the odds of having the outcome by eβ.
Just as ordinary least square regression is the method used to estimate coefficients for the best fit line in linear regression, logistic regression uses maximum likelihood estimation (MLE) to obtain the model coefficients that relate predictors to the target.
Since the documentation is poor, I found the solution through random experimentation.
The correct syntax is:
Logit(...).fit().params.values
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