Table of contents
- Logistic regression predictions and extensions
- Missing data
- Examples
- What we’ve learned so far
- Test yourself
- Coming up
1. Logistic regression predictions and extensions
1.1 Recap: Modelling a binary outcome
Logistic regression is employed when the outcome variable is binary, typically coded as 0 (absence) or 1 (presence). This type of data originates from a binomial or Bernoulli distribution.
The model utilizes a logit link function to connect the probability of the outcome to a linear combination of predictor variables, with parameters estimated via maximum likelihood 3.
- Binary data distribution: Y follows a Binomial or Bernoulli distribution, Y∼B(n,p), where P(Y=y)=(yn)py(1−p)n−y.
- Logit link function: The core of logistic regression relates the log odds of the outcome to a linear predictor: log(1−pp)=logit(p)=β0+β1X1+⋯+βkXk 3.
1.2 Recap: Simple logistic regression one continuous X
In simple logistic regression with one continuous predictor (X1), the log odds of the outcome are linearly related to X1. The intercept (β0) represents the expected log odds when X1=0, and its exponentiation (exp(β0)) gives the expected odds.
The coefficient β1 quantifies the change in log odds per unit increase in X1, while exp(β1) represents the odds ratio, indicating the multiplicative change in odds 4.
📝 For a male (where SexFemale=0) in the model log(1−p^(hypertension=yes)p^(hypertension=yes))=−1.12−0.93×SexFemale, the log odds of hypertension is −1.12 12.
1.3 Recap: Simple logistic regression one categorical X
When the predictor (X1) is categorical, the intercept (β0) represents the expected log odds of the outcome in the reference group. The coefficient β1 represents the difference in log odds between a specific category and the reference category, and its exponentiation (exp(β1)) is the odds ratio comparing that category to the reference 5.
📝 For a male aged 59 in the model logit(p^(hypertension=yes))=−3.22+0.05×Age−1.05×SexFemale, the log odds of hypertension is −3.22+0.05×59−1.05×0=−0.27 13.
1.4 Recap: Multiple logistic regression
Multiple logistic regression extends the model to include multiple predictor variables (X1,…,Xk), either to enhance predictive accuracy or to control for confounding factors. The intercept (β0) represents the expected log odds when all predictors are zero.
Each coefficient βk represents the adjusted change in log odds for a unit increase in Xk, holding all other variables constant 6.
1.5 Recap: logistic regression inference
Hypothesis testing for a coefficient βk typically involves testing H0:βk=0 against HA:βk=0. Confidence intervals (CIs) for βk are constructed using the estimated coefficient and its standard error.
For large samples, the Wald 95% CI for βk is β^k±1.96×SE(β^k) on the log odds scale. Exponentiating the bounds of this CI provides the CI for the odds ratio 7.
1.6 Model predictions
Fitted logistic regression models can be used to generate predictions on various scales: the log odds scale, the odds scale, and the probability scale. Predictions on the log odds scale are a direct result of the linear predictor β^0+β^1X1+⋯+β^kXk 8.
1.7 Probability prediction
To predict probabilities, the odds are first calculated as odds=exp(β^0+β^1X1+⋯+β^kXk). The probability p^ is then derived from the odds using the formula p^=1+oddsodds, which simplifies to p^=1+exp(β^0+⋯+β^kXk)exp(β^0+⋯+β^kXk).
This is equivalent to applying the inverse logit function, p=1+exp(x)exp(x), where x is the linear predictor 9.
The inverse logit function ensures that predicted probabilities are always between 0 and 1. However, it is crucial to note that probabilities do not change linearly with predictor variables; the relationship is sigmoidal 10.
![This line graph illustrates the sigmoid function, showing how the output probability approaches 1 as the input increases and 0 as the input decreases.](https://ixscdoswnqhohheqmami.supabase.co/storage/v1/object/public/documents/b865b7d1-7f21-457f-9137-917ecf8ab6ba/courses/ff822a28-bc0b-4723-b129-acad0036ca49/figures/a