1

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? ​

mountainave
  • 87
  • 1
  • 5
  • 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, https://github.com/statsmodels/statsmodels/issues/2181 – Josef Jul 16 '21 at 15:09

1 Answers1

1

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

Dave
  • 28,473
  • 4
  • 52
  • 104
  • To confirm, when you say P(1) and "log-odds of 1," by "1" you're referring to dependent_variable == 1, correct? – mountainave Jul 14 '21 at 21:07
  • I am. So I follow your reasoning, what else could it be? – Dave Jul 14 '21 at 21:08
  • 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). – mountainave Jul 14 '21 at 21:12
  • 1
    I mean the log-odds (or probability) of the event coded as $1$, yes. – Dave Jul 14 '21 at 21:14