| Predicted 1 | Predicted 0 | |
|---|---|---|
| Actual 1 (fav. won) | –TP | –FN |
| Actual 0 (fav. lost) | –FP | –TN |
| Accuracy (TP + TN) / n | – |
| Sensitivity TP / (TP + FN) | – |
| Specificity TN / (TN + FP) | – |
| Precision TP / (TP + FP) | – |
| Area under the ROC curve | – |
Each dot is a simulated NBA game: the Vegas point spread on the x-axis, and whether the favorite won (1) or lost (0). The red S-curve is the reference model with β = 0.156. Fit the model by maximum likelihood, read off win probabilities, and move the cutoff to see the confusion matrix and the ROC curve change.
← All labsBased on Chapter 13, Logistic Regression and Generalized Linear Models, of Polson and Sokolov, Bayes, Artificial Intelligence, and Deep Learning (vsokolov.org/html/_book).
| Predicted 1 | Predicted 0 | |
|---|---|---|
| Actual 1 (fav. won) | –TP | –FN |
| Actual 0 (fav. lost) | –FP | –TN |
| Accuracy (TP + TN) / n | – |
| Sensitivity TP / (TP + FN) | – |
| Specificity TN / (TN + FP) | – |
| Precision TP / (TP + FP) | – |
| Area under the ROC curve | – |
The model is linear on the log-odds scale. Exponentiate to get odds, then divide odds by one plus odds to get a probability. These buttons load the worked cases.
A straight line through 0/1 data predicts values below 0 and above 1 once the spread is large enough. We want P(Y = 1 | X), which must stay in (0, 1). The logistic curve does that for any value of β₀ + β₁X.
Each extra point of spread adds 0.156 to the log-odds that the favorite wins. Equivalently, it multiplies the odds by e0.156 = 1.17. The change in probability per point is not constant: the curve is steepest at 50% and flattens near 100%.
There is no least-squares formula here. R's glm, and this page, climb the log-likelihood with Newton–Raphson steps (iteratively reweighted least squares). The standard error comes from the curvature of the log-likelihood at the top.
With no intercept and a positive spread, every p̂ is above 0.5, so the 0.5 cutoff always picks the favorite. Sensitivity is 100% and specificity is 0%. Raise the cutoff and the model starts calling upsets in close games. The ROC curve shows every cutoff at once, and its area (AUC) is the chance that a random win gets a higher p̂ than a random loss.
Takeaway for students. The reference 65% and 77% come straight from plugging the spread into the fitted curve. The market looks calibrated because the curve passes through the observed win rates. Whether to call a game for the underdog is a separate business decision, set by the cutoff and the cost of each kind of mistake.
Each dot is one simulated Grand Slam match, placed at the break points won by player 1 (x) and player 2 (y). The reference fit glm(Result ~ BPW.1 + BPW.2 − 1) on 943 real matches from 2013. With two predictors, the set of matches where p̂ = 0.5 is a straight line.
β̂₁ = 0.402 and β̂₂ = −0.418 are close to equal and opposite. Winning a break point helps player 1 about as much as losing one hurts. So the boundary is close to the 45° line BPW.2 = BPW.1, tilted slightly by the ratio 0.402 / 0.418 = 0.96.
The reference fit approximates both coefficients by 0.40. Then a gap of three break points gives 0.40 × 3 = 1.2 on the log-odds scale, and p̂ = 77%, up from 50% at parity. That is 27 percentage points.
In the LinkedIn example a top MBA has β̂ = +1.16, so it multiplies the odds of becoming VP, CXO or partner by e1.16 = 3.19. A year of experience multiplies them by e0.09 = 1.09. The ratio 1.16 / 0.09 ≈ 13 is the "worth 13 years" result.
| Feature | β̂ | eβ̂ |
|---|---|---|
| Top MBA | +1.16 | 3.19 |
| Function count | +0.26 | 1.30 |
| Years of experience | +0.09 | 1.09 |
| Industry count | −0.22 | 0.80 |