Track 9 · Correlation and Regression · Lesson 14 of 15
Logistic regression
Fit a logistic regression for a yes/no outcome, interpret its coefficients as odds ratios (not risk ratios), predict probabilities, and judge a classification threshold.
A lender wants to know which applicants are more likely to default and by how much each risk factor matters. The outcome is yes or no, so a straight line for the probability would predict impossible values below 0 or above 1. Logistic regression models the probability on a scale where a linear model makes sense — the log-odds.
The loans dataset has 3 000 approved personal loans; defaulted is 1 if the borrower fell 90+ days behind within 24 months. The overall default rate is 12.9%. A probability lives between 0 and 1, so we transform it twice:
- Odds : a 20% chance of default is odds of 0.25 (“1 to 4”); odds range from 0 to ∞.
- Log-odds (logit) : ranges over all real numbers, so a linear model cannot produce impossible values.
Included with a Formula Quest membership
It has 7 graded exercises with feedback, hints and worked solutions. After it you will be able to:
- Convert between probability, odds and log-odds
- Interpret logistic coefficients as odds ratios, holding other predictors fixed
- Explain why an odds ratio is not a risk ratio when the outcome is common
- Predict probabilities from a fitted logistic model
- Evaluate a threshold with sensitivity, specificity and precision