Try it in R: Mathematical Simplicity
A linear or logistic regression is easy to call in software (glm(y ~ x, family = binomial)), which makes its algebraic formula feel “simple”. Gelman and Nolan’s golf-putting example shows why scientific simplicity and algebraic simplicity often disagree: a model built from the geometry of the ball and the hole has only one parameter with a direct physical meaning, and it extrapolates sensibly where logistic regression fails.
Step 1: Geometry vs. logistic regression on putts from 2 to 20 feet
A golf ball (radius \(r_{\text{ball}} = 1.68 / 2\) inches) drops into a hole (radius \(r_{\text{hole}} = 4.25 / 2\) inches) at distance \(x\) feet if the golfer’s angular error \(\theta \sim \mathrm{N}(0, \sigma^2)\) falls within \(\pm \arcsin\!\big((r_{\text{hole}} - r_{\text{ball}}) / x\big)\):
\[ \Pr(\text{make at distance } x) = 2\,\Phi\!\left(\frac{\arcsin((r_{\text{hole}} - r_{\text{ball}}) / x)}{\sigma}\right) - 1. \]
Run the cell below to simulate putts from 2 to 20 feet, fit both the 1-parameter geometric model (with optimize()) and a 2-parameter logistic regression (with glm()), and extrapolate both out to 40 feet.
Predict → Modify → Observe
- Look at 40 feet. In the printed numbers at the bottom, compare
truth_40ft(~19% make rate) withlogistic_40ft(~1% make rate). Because logistic regression forces log-odds to fall linearly with feet, it plunges toward zero far too fast at long distances. - Train on an even narrower window. Change
x <- 2:20on line 9 tox <- 2:10(only short putts observed) and click Run Code. Does the 1-parameter geometric model still recover the 20-foot and 40-foot curve accurately? - Compare AIC. Add
AIC(fit)versus2 * 1 + 2 * nll(sigma_hat)(1 parameter plus \(2 \times \text{negative log-likelihood}\)). Which model has the better (lower) AIC even inside the observed range?
Your turn: add distance control to the geometric model
In a follow-up post, Gelman added a second physical mechanism: to sink a putt, the golfer must both aim within the angle tolerance and hit the ball with the right speed (where distance error scales with distance \(x\)). If the probability of good distance control at distance \(x\) is p_dist(x, sigma_d), and angle and distance errors are independent, the combined probability of making the putt is the product of the two probabilities.
Complete p_both(x, sigma_angle, sigma_dist) below and compare the make curve with and without distance error.
For two independent events (good angle and good distance), multiply their probabilities: p_geo(x, sigma_angle) * p_dist(x, sigma_d).
p_dist <- function(x, sigma_d) {
pnorm(1.5 / (sigma_d * x)) - pnorm(-0.5 / (sigma_d * x))
}
p_both <- function(x, sigma_angle, sigma_d) {
p_geo(x, sigma_angle) * p_dist(x, sigma_d)
}
grid <- seq(2, 40, by = 0.5)
plot(grid, p_geo(grid, 1.5 * pi / 180),
type = "l", col = "#2166ac", lwd = 2, ylim = c(0, 1),
xlab = "Distance (feet)", ylab = "Probability of success"
)
lines(grid, p_both(grid, 1.5 * pi / 180, sigma_d = 0.08),
col = "#1a9850", lwd = 2
)
legend("topright", c("Angle only", "Angle + distance control"),
col = c("#2166ac", "#1a9850"), lwd = 2, bty = "n"
)
Show simulation code
p_dist <- function(x, sigma_d) {
pnorm(1.5 / (sigma_d * x)) - pnorm(-0.5 / (sigma_d * x))
}
p_both <- function(x, sigma_angle, sigma_d) {
p_geo(x, sigma_angle) * p_dist(x, sigma_d)
}
grid <- seq(2, 40, by = 0.5)
plot(grid, p_geo(grid, 1.5 * pi / 180),
type = "l", col = "#2166ac", lwd = 2, ylim = c(0, 1),
xlab = "Distance (feet)", ylab = "Probability of success"
)
lines(grid, p_both(grid, 1.5 * pi / 180, sigma_d = 0.08),
col = "#1a9850", lwd = 2
)
legend("topright", c("Angle only", "Angle + distance control"),
col = c("#2166ac", "#1a9850"), lwd = 2, bty = "n"
)Where next
- Read the full entry: Mathematical Simplicity.
- Return to all R labs or continue exploring the Start here tour.