The logistic squeeze
A logistic regression is a linear regression in disguise. It fits a straight line to a logit — an unbounded score — and then pushes every point on that line through a function that can only return values between 0 and 1. Move x and watch one observation land on the regression line, then get squeezed into a probability.
The linear predictor z = B0 + B1x
z is the linear predictor: an ordinary regression line, unbounded, positive or negative.
The squeeze p = ez ⁄ (1 + ez)
The logistic function is the inverse of the logit link, log(p ⁄ (1 − p)) = z. It takes the linear predictor z (which is just the linear equation, z = B0 + B1x) and returns a p strictly between 0 and 1. The dashed line is where the straight line would go if nothing stopped it.
Try this, in order
- Find the midpoint. Leave B0 = 0 and B1 = 1. Slide x to 0. The logit is 0 and the probability is exactly ½. Now nudge x just above and just below 0 and watch p cross ½ each time.
- Push the logit far out. Slide x to 5, then to −5. The line on the left keeps climbing (or falling) without limit; the dot on the right barely moves once it nears 1 or 0. That flattening is the squeeze.
- Shift the line. With x = 0, move B0 to 2 and then to −2. The whole line slides up or down, the crossing point x* moves, and p at x = 0 is no longer ½. Where is it now, and why?
- Tilt the line. Put B0 back to 0 and set B1 to 3. The curve becomes a near-cliff: tiny changes in x near the midpoint swing p dramatically. Now set B1 to 0.3 and notice the curve is almost a straight line across the whole window.
- Flip the sign. Set B1 to −1. The curve falls instead of rises, and the regime labels swap sides. Confirm that z > 0 still means p > ½; only where z is positive has changed.
- Test the “one-unit change” claim. With B0 = 0 and B1 = 1, read off p at x = 0 and x = 1, then at x = 4 and x = 5. Both are one-unit moves in x and identical one-unit moves in z. Are the changes in p the same? This is why a logistic coefficient is not a constant change in probability.
- Compare the dashed line with the curve. The dashed line on the right is the straight-line version of the relationship — where a plain linear regression would send the prediction. With B1 = 1, slide x out toward the edges. Where do they agree, and where does the dashed line leave the 0–1 band while the curve refuses to?
- Turn the probability back into a 0 or 1. With B0 = 0 and B1 = 1, put x at 0.5 so p is just above the 0.5 threshold and the readout says “1”. Now raise the threshold to 0.7: same x, same p, but the call flips to “0”. Nothing about the model changed — only your rule for converting a probability into a decision. Which kind of mistake did you just make more likely?
- z < 0ez is smaller than 1, so ez ⁄ (1 + ez) is less than a half. p < 0.5
- z = 0e0 = 1, so the ratio is 1 ⁄ 2 exactly. p = 0.5
- z > 0ez is bigger than 1, so the ratio is more than a half. p > 0.5
Getting back to 0 or 1
The data that went in were binary: every outcome was a 0 or a 1, nothing in between. What comes out is a probability, which can be anything in between. So the model never hands back the original form of the dependent variable on its own — you have to choose a threshold and declare everything above it a 1 and everything below it a 0.
That choice creates two ways to be wrong. Call a true 0 a 1 and you have a false positive (a Type I error). Call a true 1 a 0 and you have a false negative (a Type II error). Raising the threshold trades false positives for false negatives; lowering it trades the other way. The model does not tell you which error is worse — that depends on what a 1 and a 0 cost in the world the data came from.
Logistic regression is one member of the family of generalized linear models (GLMs): models that fit a straight line to the predictors and then pass it through a link function so the output matches the kind of outcome at hand — a probability here, a count in Poisson regression, and ordinary linear regression when the link is the identity function — the function that returns its input unchanged, so the line is the prediction, with no squeeze at all. In GLM terms, with a single predictor: the linear predictor is z = B0 + B1x; the link function is the logit, log(p ⁄ (1 − p)) = z, which maps a probability onto the line. The logit is the log of the odds, where the odds are the probability of a 1 divided by the probability of a 0: odds = p ⁄ (1 − p). A probability of 0.75 is odds of 3 to 1; a probability of 0.5 is odds of 1 to 1, whose log is 0; and the logistic function is the link's inverse, mapping the line back to a probability. Where the line crosses zero is where the curve crosses one half: at x* = −B0 ⁄ B1. The sign of B1 decides whether the curve rises or falls; its size decides how steep the squeeze is. Near z = 0 the curve is almost straight (slope ¼ per unit of z); far from it, the curve goes flat and extra logit buys almost no extra probability.