In logistic regression: $log(\frac{p(x)}{1-p(x)}) = \beta_0 + \beta_1x$,

let $x' = \frac{x-\bar{x}}{\sigma_x}$, then in terms of the centered and scaled varaible $x'$ , $$ log(\frac{p(x')}{1-p(x')}) = \beta_0' + \beta_1'x' = \beta_0' - \frac{\beta_1'}{\sigma_x}\bar{x} + \frac{\beta_1'}{\sigma_x}x $$ Since $log(\frac{p(x)}{1-p(x)}) = log(\frac{p(x')}{1-p(x')})$, then $$ \beta_1 = \frac{\beta_1'}{\sigma_x} \\ \beta_0 = \beta_0' - \frac{\beta_1'}{\sigma_x}\bar{x} = \beta_0' - \beta_1\bar{x} $$ (In logistic regression, intercept is the log odds only when other predictors are 0. )

Note the intercept $\beta_0'$ is not zero. But in the linear regression case, after centering and standardization, the intercept is 0, so there is no need to penalize the intercept.

Questions: in the logistic regression case, do we need to penalize the intercept ($\beta_0'$) after centering and scaling the data x?


In linear regression, if you center and scale x, the OLS (unregularized) intercept is the mean of y. In some cases, x and y are both centered and scaled; in that rescaled space, the intercept is 0 (which gives an unregularized intercept in the original space).

In logistic regression, if you center and scale x, you will still need an intercept. People generally do not penalize the intercept because they want full flexibility of the intercept. If you have prior belief that the intercept should be zero, then penalize it.

  • $\begingroup$ thanks for the quick response, I was a bit confused when coding the logistic regression. I think I am going to accept the answer, just curious if you have some example/reference to the statement "People generally do not penalize ..." $\endgroup$ – vtshen Nov 9 '18 at 22:43
  • 1
    $\begingroup$ @vtshen It's sort of a rule of thumb people have. Penalized models are equivalent to MAP estimation of Bayesian models. When a coefficient is unpenalized, you are giving it uniform prior probability of taking on any value. People generally have no strong belief about the intercept, in linear regression nor in logistic regression, hence they don't penalize it. In linear regression if you center x, the intercept reflects the mean of y. By not penalizing y, you are saying your prior belief is not that y's mean is no more likely to be 0 than other values. $\endgroup$ – Wart Nov 9 '18 at 22:49
  • $\begingroup$ @vtshen, I should also add that it is the default in almost any package for the intercept to be unregularized. In fact, they often don't even mention it. See here: stackoverflow.com/questions/26126224/… $\endgroup$ – Wart Nov 9 '18 at 22:53
  • $\begingroup$ Got it. The argument is very useful. Thanks again for the help $\endgroup$ – vtshen Nov 9 '18 at 23:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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