1
$\begingroup$

I'm running logistic regressions in Python using statsmodels logit. My dependent variable is binary, 0 or 1.

How do I know whether the regression is modeling an outcome of 1 or an outcome of 0 for the dependent variable? (And, therefore, whether the coefficients correspond to an outcome of 1 or 0?)

For example, one of the parameters, age, has a positive coefficient of 0.03. How do I know whether age is positively correlated with outcome == 1, or positively correlated with outcome == 0? ​

$\endgroup$
1
  • $\begingroup$ in statsmodels: if the response variable is numeric 0, 1, then 1 is the event, i.e. predict Prob(y=1 | x). However, if the response variable is categorical and formulas are used, then the formula conversion flips the order of 0 and 1, github.com/statsmodels/statsmodels/issues/2181 $\endgroup$
    – Josef
    Commented Jul 16, 2021 at 15:09

1 Answer 1

1
$\begingroup$

Logistic regression predicts $P(1)$, and we get $P(0)$ via $1-P(1)$. Remember that the GLM deals with a binomial response variable that models the probability of getting a "success", defined as $1$ in the usual way we define the binomial PMF.

Therefore, a coefficient of $0.03$ means that, for every one-unit increase in the corresponding variable, expect an increase of $0.03$ in the log-odds of $1$.

(Always keep in mind that logistic regression is predicting a log-odds (or a probability, depending how you elect to look at it), not a discrete outcome. Predicting discrete outcomes is surprisingly problematic.)

$\endgroup$
4
  • $\begingroup$ To confirm, when you say P(1) and "log-odds of 1," by "1" you're referring to dependent_variable == 1, correct? $\endgroup$ Commented Jul 14, 2021 at 21:07
  • $\begingroup$ I am. So I follow your reasoning, what else could it be? $\endgroup$
    – Dave
    Commented Jul 14, 2021 at 21:08
  • $\begingroup$ Well, I guess dependent variable could alternatively be zero. But if I understand you correctly, it sounds like the default for logistic regression is always for the model to predict P(1). $\endgroup$ Commented Jul 14, 2021 at 21:12
  • 1
    $\begingroup$ I mean the log-odds (or probability) of the event coded as $1$, yes. $\endgroup$
    – Dave
    Commented Jul 14, 2021 at 21:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.