Yes, you can think of logistic regression as a type of Generalized Linear Model (GLM) where the linear regression model is applied to a transformation of the outcome variable.
Here's a breakdown:
-
Linear Regression:
- Models the relationship between independent variables (X) and a continuous dependent variable (Y) directly.
- The equation is:
Y = β₀ + β₁X₁ + β₂X₂ + ... + βₚXₚ + ε
- It assumes Y is normally distributed and the relationship is linear.
- The output
Y can range from -∞ to +∞.
-
The Problem with Using Linear Regression for Classification:
- If you try to predict a binary outcome (0 or 1) directly with linear regression, the predicted values can go outside the 0-1 range, which doesn't make sense for probabilities.
- The assumption of normality of errors is violated.
-
Logistic Regression's Approach:
-
Instead of modeling the binary outcome (0 or 1) directly, or even the probability p directly, logistic regression models the log-odds (also called the logit) of the probability linearly.
-
Probability (p): The probability of the event occurring (e.g., Y=1). Ranges from 0 to 1.
-
Odds: p / (1-p). Ranges from 0 to +∞.
-
Log-odds (Logit): log(p / (1-p)). Ranges from -∞ to +∞.
-
The core linear equation in logistic regression is:
log(p / (1-p)) = β₀ + β₁X₁ + β₂X₂ + ... + βₚXₚ
-
This log(p / (1-p)) is the transformation of the original probability p.
-
The right-hand side (β₀ + β₁X₁ + ...) is the standard linear combination you see in linear regression.
-
Getting Back to Probability:
- To get the probability
p back from the log-odds, we use the inverse of the logit function, which is the logistic function (or sigmoid function):
p = 1 / (1 + exp(-(β₀ + β₁X₁ + ... + βₚXₚ)))
- This function ensures that
p is always between 0 and 1.
So, to directly answer your question:
Yes, logistic regression uses a linear combination of inputs (like linear regression), but this linear combination predicts the log-odds of an event. The relationship between the independent variables and the log-odds of the outcome is linear. The logistic (sigmoid) function then transforms this linear output back into a probability (between 0 and 1).
In the framework of Generalized Linear Models (GLMs):
- Linear Predictor:
η = β₀ + β₁X₁ + ... (same as in linear regression)
- Link Function: Connects the linear predictor to the expected value of the outcome. For logistic regression, the link function is the logit function:
η = logit(E[Y]) = log(p/(1-p)).
- Random Component: Specifies the probability distribution of the outcome. For logistic regression, it's the Bernoulli distribution (for binary outcomes).
So, logistic regression is a GLM that uses a linear model for the logit-transformed probability of a Bernoulli-distributed outcome.