When is binary, a count, or non-negative, OLS gives nonsense (negative probabilities, fractional counts). Generalized Linear Models (GLMs) fix this by linking the mean of to through a link function.
Logistic regression handles binary :
Fit by maximum likelihood. The coefficients have a clean interpretation as changes in log-odds.
Other widely used GLMs:
- Poisson regression for count data uses .
- Gamma regression for positive continuous data uses .
The general recipe is: pick an exponential-family distribution for and a link function relating its mean to . Interpretation becomes nonlinear, but residual diagnostics, regularization, and inference all carry over from OLS.