

Logistic Regression
Grayson White
Stat 243
Fall 2026, Week 8
Two brothers, George and Jacob decide to leave Illinois and lead a group of migrants to head west to California.
Expected trip duration: four to six months
Slowed by taking a new route, the Hastings Cutoff, which crossed the Wasatch mountains and Great Salt Lake Desert.

Two brothers, George and Jacob decide to leave Illinois and lead a group of migrants to head west to California.
Expected trip duration: four to six months
Slowed by taking a new route, the Hastings Cutoff, which crossed the Wasatch mountains and Great Salt Lake Desert.
In early November, the “Donner Party” is trapped by an early snowfall in the Sierra Nevada mountains.

# A tibble: 45 × 4
Age Sex Status Survived
<int> <fct> <fct> <dbl>
1 23 Male Died 0
2 40 Female Survived 1
3 40 Male Survived 1
4 30 Male Died 0
5 28 Male Died 0
6 40 Male Died 0
7 45 Female Died 0
8 62 Male Died 0
9 65 Male Died 0
10 45 Female Died 0
# ℹ 35 more rows
We’d like to describe the relationship between survival in the Donner Party and other recorded variables: Sex and Age


Model Form:
\[ \begin{align} y &= \beta_0 + \beta_1 x_1 + \beta_2 x_2 + \cdots + \beta_p x_p + \epsilon \end{align} \]
Linear regression is a flexible class of models that allow for:
Both quantitative and categorical explanatory variables.
Multiple explanatory variables.
BUT the response variable is quantitative.
Model Form:
\[ \begin{align} y = P(\text{survival}) = \beta_0 + \beta_1 x_{age} + \beta_2 x_{sex} + \epsilon \end{align} \]

Think-Pair-Share:
What do the regression lines represent?
What is the estimated probability of survival for 20 year old female members of the Donner Party?
What about the estimated probability of survival for 65 year old male members?
02:00
What is the estimated probability of survival for 20 year old female members of the Donner Party?
What about the estimated probability of survival for 65 year old male members?


Logistic regression can be used when:
Response variable: A categorical variable with two categories
\[\begin{align*} Y = \left\{ \begin{array}{ll} 1 & \mbox{success} \\ 0 & \mbox{failure} \\ \end{array} \right. \end{align*}\]\(Y \sim\) Bernoulli\((p)\) where \(p = P(Y = 1) = P(\mbox{success})\).
Explanatory variables: Can be a mix of categorical and quantitative
Goal: Build a model for \(P(Y = 1)\).
Regression line = estimated probability of success
For valid values of \(x\), we are predicting the probability is less than 0 or greater than 1.

Regression line = estimated probability of success
For valid values of \(x\), we are predicting the probability is less than 0 or greater than 1.
The estimated probabilities based on the logistic regression model are bounded between 0 and 1.

What does the logistic regression model look like?
Left hand side has many interpretations:
\[\begin{align*} \mbox{LHS} &= \log\left(\frac{P(Y = 1)}{1 - P(Y = 1)} \right)\\ &= \log \left( \mbox{odds (of success)} \right)\\ &= \mbox{logit}(P(Y = 1)) \end{align*}\]Note:
\[ \mbox{odds} = \frac{\mbox{prob of success}}{\mbox{prob of failure}} \]
Q: If \(P(Y = 1) = 0.8\), what are the odds of success?
\[ \text{odds} = \frac{P(Y=1)}{1 - P(Y=1)} = \frac{0.8}{1 - 0.8} = 4 \]
Q: What is the maximum value the odds can take? What about the minimum? What about for \(\log(\text{odds})\)?

RInstead of a linear regression model, let’s fit a logistic regression model to the Donner Party data!
# A tibble: 2 × 5
term estimate std.error statistic p.value
<chr> <dbl> <dbl> <dbl> <dbl>
1 (Intercept) 0.693 0.548 1.27 0.206
2 SexMale -1.39 0.671 -2.07 0.0388
Fitted model: \[ \log\left(\frac{P(Y = 1)}{1 - P(Y = 1)} \right) = 0.693 - 1.386 x_{Sex:Male} \]
What do the coefficient estimates \(\hat{\beta}_0 = 0.693\) and \(\hat{\beta}_1 = - 1.386\) represent?
Sex = “Female”:Therefore, \(\hat\beta_0\) represents the \(\log\) of the odds of survival for the baseline group.
Sex = “Male”:Therefore, \(\hat\beta_1\) represents the change in the \(\log\) odds of survival when comparing the baseline group (Female) to Male.
Is there a more intuitive way to interpret logistic regression coefficients?
(1) Odds:
\[\text{odds} = \frac{\text{prob of success}}{\text{prob of failure}} = \frac{P(Y = 1)}{1 - P(Y = 1)}\]
and (2) the logistic regression model:
\[\log\left(\frac{P(Y = 1)}{1 - P(Y = 1)}\right) = \beta_0 + \beta_1 x_1\]
So then
\[\text{odds} = \exp\left(\beta_0 + \beta_1 x_1\right)\]
(Estimated) odds of survival for female members of the Donner Party:
\[\exp\left(\hat{\beta}_0\right)\]
(Estimated) odds of survival for male members of the Donner Party:
\[\exp\left(\hat{\beta}_0 + \hat{\beta}_1\right)\]
What about interpreting \(\hat\beta_1\) on it’s own?
Odds ratio: Comparison of odds between two groups
\[\text{odds ratio} = \frac{\text{odds of group 1}}{\text{odds of group 2}}\]
Interpretation of odds ratio: The odds of success in group 1 are ___ times the odds of success in group 2.
Note: Also useful property:
\[\exp(a + b) = \exp(a) \exp(b)\]
Computing the odds ratio:
\[\frac{\exp\left(\hat{\beta}_0 + \hat{\beta}_1 \right)}{\exp\left(\hat{\beta}_0 \right)} = \frac{\exp(\hat{\beta}_0)\exp(\hat{\beta}_1 )}{\exp(\hat{\beta}_0)} = \exp(\hat{\beta}_1)\]
How do we interpret \(\hat{\beta}_1 = - 1.386\)?
\[\exp(\hat{\beta}_1) = \frac{\text{odds of survival if male} }{\text{odds of survival if female }}\]
The estimated odds of survival for female members of the Donner Party are about 4 times that of male members!
What about quantitative predictors?
# A tibble: 3 × 5
term estimate std.error statistic p.value
<chr> <dbl> <dbl> <dbl> <dbl>
1 (Intercept) 3.23 1.39 2.33 0.0198
2 SexMale -1.60 0.755 -2.11 0.0345
3 Age -0.0782 0.0373 -2.10 0.0359
The estimated odds of survival for female members of the Donner Party is nearly 5 times that of male members, holding age constant.
(Estimated) odds of survival for \(x_{age} = t\) years:
\[\exp\left(\hat{\beta}_0 + \hat{\beta}_1 x_{1} + \hat{\beta}_2 t\right)\]
(Estimated) odds of survival for \(x_{age} = t + 1\) years:
\[\exp\left(\hat{\beta}_0 + \hat{\beta}_1 x_1 + \hat{\beta}_2 (t + 1)\right)\]
odds ratio:
\[\frac{\exp\left(\hat{\beta}_0 + \hat{\beta}_1 x_{1} + \hat{\beta}_2 (t + 1)\right)}{\exp\left(\hat{\beta}_0 + \hat{\beta}_1 x_{1} + \hat{\beta}_2 t\right)} = \frac{\exp\left(\hat{\beta}_0\right)\exp\left(\hat{\beta}_1 x_{1}\right) \exp\left(\hat\beta_2 (t + 1)\right)}{\exp\left(\hat{\beta}_0\right)\exp\left(\hat{\beta}_1 x_{1}\right) \exp\left(\hat\beta_2 t\right)} = \exp(\hat{\beta}_2)\]
How do we interpret \(\hat{\beta}_2 = -0.078\)?
\[\exp(\hat{\beta}_2) = \frac{\text{odds of surviving at age } (t + 1)}{\text{odds of surviving at age t}}\]
How can I use this model to predict, for a given sex and age:
How can I use this model to predict, for a given sex and age:
\[ \text{odds} = \frac{P(Y = 1)}{1 - P(Y = 1)} = \exp\left(\hat\beta_0 + \hat\beta_1x_1 + \hat\beta_2x_2\right) \]
How can I use this model to predict, for a given sex and age:
How can I use this model to predict, for a given sex and age:
\[ P(Y = 1) = \frac{\exp\left(\hat\beta_0 + \hat\beta_1x_1 + \hat\beta_2x_2\right)}{1 + \exp\left(\hat\beta_0 + \hat\beta_1x_1 + \hat\beta_2x_2\right)} \]
How can I use this model to predict, for a given sex and age:
We can use the predicted probability at for an individual to help us predict the binary outcome.
\[\widehat{P(Y = 1)} \geq 0.5 \rightarrow \hat{y} = 1\] \[\widehat{P(Y = 1)} < 0.5 \rightarrow \hat{y} = 0\]
# A tibble: 4 × 3
# Groups: Survived [2]
Survived pred_survived n
<dbl> <dbl> <int>
1 0 0 23
2 0 1 2
3 1 0 8
4 1 1 12
Today, we learned about logistic regression, a model suitable when your response variable is categorical and binary, but your predictors can be categorical or quantitative.
\[ \log\left(\frac{P(Y = 1)}{1 - P(Y = 1)} \right) = \beta_0 + \beta_1 x_1 + \beta_2 x_2 + \cdots + \beta_p x_p \]
Unlike linear regression models, logistic regression models always predict the probability of success to be between 0 and 1.
We have to interpret odds and odds ratios to interpret the coefficients.
We can predict many quantities: odds of success, probability of success, and even whether or not we expect success!