Generalized Linear Models
The recipe for fitting a straight-line-style model to outcomes that aren't shaped like a bell curve — counts, probabilities, yes/no events — by bending the line through a link function before it meets the data.
Prerequisites: Logistic Regression, Maximum Likelihood Estimation (MLE)
Ordinary linear regression fits a straight line to your outcome and assumes the leftover noise is a symmetric bell curve, evenly spread everywhere. That works fine when the outcome is something like a return, which can be any real number. It falls apart the moment the outcome is a probability that must stay between 0 and 1, or a count that must stay non-negative, or a binary "did the trade fill or not." Fit a straight line to a 0/1 outcome and it will happily predict a probability of 1.4 or , which is meaningless. A generalized linear model is the fix: keep the linear part — you still add up weighted predictors — but pass the result through a bending function first, one chosen to match the shape the outcome is actually allowed to take.
An analogy: a valve, not a straight pipe
Think of ordinary regression as water flowing straight through a pipe: pour in more pressure (predictors), get out proportionally more flow (outcome), no limit either direction. Now imagine the outcome has to obey a physical limit — say it's the fill level of a tank that can't go below empty or above full. You wouldn't connect the pressure straight to the fill level; you'd put a valve in between that translates "more pressure" into "closer to full" in a way that naturally flattens out near the two limits and never overshoots them. The valve is the link function. It lets you keep using a simple, additive combination of your predictors on the inside, while guaranteeing the outcome that comes out the other side always lives in the right range.
The model, one symbol at a time
Let be the outcome and the predictors. First build the linear predictor, exactly as in ordinary regression:
In words: ("eta") is just the familiar weighted sum of predictors — still linear, nothing new yet. Then choose a link function that connects to the mean of the outcome, ("mu"):
In words: the link function is the rule that translates between the unrestricted linear predictor and the restricted, meaningful mean of the outcome; is the valve that un-does the link and produces the actual prediction. For binary outcomes the usual choice is the logit link,
In words: the logit turns a probability into "log-odds," which can range over all real numbers, so the linear predictor is free to be linear; inverting it (the logistic function) squeezes any real number back into a valid probability between 0 and 1. For count outcomes the standard choice is the log link, , so , which guarantees the predicted count is always positive since can never go negative.
Finally, a GLM also specifies a distribution family for the noise around — Bernoulli for binary outcomes, Poisson for counts, Gaussian (which recovers ordinary regression) for continuous unbounded ones. The parameters are fit by maximum likelihood, not by minimizing squared error, because squared-error fitting silently assumes the Gaussian shape that no longer applies.
A GLM keeps regression's additive, linear core but routes it through a link function matched to the outcome's shape, and fits it by maximum likelihood instead of least squares. The line lives on an unrestricted scale; the prediction lives on the scale the data actually occupies.
Worked example 1: logistic regression by hand, one step of fitting
You're modeling whether a trade fills () or not () using order size (in $10k units). Suppose the fitted model is . At (a $40k order):
So a $40k order is predicted to fill 73.1% of the time. At : , , a 26.9% fill chance for a tiny order. Notice the change in probability per unit of is not constant — from to ( from to ), moves from 0.269 to 0.378, a jump of 0.109; from to ( from to ), moves from 0.622 to 0.731, a jump of 0.109 as well here because we're near the steepest part of the S-curve — but near either extreme, the same 0.5 change in moves by only a few points. That non-constant sensitivity is exactly the point of the link: probabilities compress near 0 and 1, and the logit is what makes that compression automatic.
Worked example 2: Poisson regression for trade counts
You model the number of trades per hour, , as a function of volatility (in vol points), with fitted log link . At : , so trades expected per hour. At : , trades per hour. Doubling volatility from 5 to 10 didn't double the linear predictor's effect additively — it multiplied the predicted count by . This is the signature of the log link: a one-unit increase in multiplies the predicted count by , a constant factor, rather than adding a constant amount — which matches how trading activity actually behaves, scaling up multiplicatively rather than by fixed increments.
Try raising the rate parameter in the explorer above and notice the distribution stays non-negative and right-skewed at low rates — exactly the shape a Poisson GLM is built to predict, and exactly the shape ordinary linear regression cannot respect.
What this means in practice
- Logistic regression for fill probabilities, default probabilities, up/down classification — anywhere the outcome is a probability of an event.
- Poisson or negative-binomial regression for trade counts, order arrivals, defaults per period — anywhere the outcome is a non-negative count.
- Coefficients are on the link scale, not the outcome scale. In logistic regression, is a change in log-odds, not in probability; you must convert through the inverse link before quoting an effect in probability terms, and the size of that effect depends on where on the curve you start.
- Diagnostics differ from OLS. Residuals aren't expected to look Gaussian; instead use deviance residuals and compare nested models with a likelihood ratio test.
The classic confusion: treating a GLM coefficient like an ordinary regression coefficient — "a one-unit increase in increases the outcome by ." That statement is only true on the link scale (log-odds, log-count), never on the outcome scale, because the link function is nonlinear. A logistic regression coefficient of does not mean "probability goes up by 0.5 per unit of "; the actual probability change depends on the starting point, as worked example 1 showed — the same produces a small effect near the extremes and a large effect near 50%. Always convert through before interpreting magnitudes in the units people actually care about.
Related concepts
Practice in interviews
Further reading
- McCullagh & Nelder, Generalized Linear Models, ch. 2
- Nelder & Wedderburn (1972), Journal of the Royal Statistical Society