Tutorials › Generalized Linear Models › From Linear Predictors to Fitted Probabilities

Binary Logistic Regression · Tutorial 347 of 981

From Linear Predictors to Fitted Probabilities

Learn how a logistic linear predictor determines a fitted probability, why that probability is always between zero and one, and how to calculate it reliably.

Intermediate 10 min read

What You'll Learn

  • Derive the inverse-logit formula by solving the logit equation for probability
  • Prove that the inverse-logit maps every finite real predictor to a probability strictly between zero and one
  • Establish that the transformation is strictly increasing and describe its limiting behavior
  • Calculate fitted probabilities by substituting estimated coefficients into the linear predictor
  • Evaluate the inverse-logit stably for both positive and negative predictors
  • Identify common errors when interpreting or calculating fitted probabilities

From a Linear Predictor to a Probability

In Bernoulli logistic regression, the model connects the probability of an outcome to a linear predictor. The predictor is a real number, while a probability must lie between zero and one. The inverse-logit transformation makes that connection: it converts a predictor into a valid probability without imposing any additional restriction on the predictor’s possible real values.

For observation \(i\), write the linear predictor as \(\eta_i\), and let \(p_i=P(Y_i=1\mid x_i)\) be the conditional probability of the event coded as 1. The logistic model specifies that the logit of this probability equals the linear predictor. Once coefficient estimates are available, substituting them into that predictor gives a fitted probability.

Definition: For \(0<p<1\), the logit function is \(\operatorname{logit}(p)=\log\!\left(\frac{p}{1-p}\right)\). Its inverse, the inverse-logit (also called the logistic function), is \[ \operatorname{logit}^{-1}(\eta)=\frac{\exp(\eta)}{1+\exp(\eta)},\qquad \eta\in\mathbb{R}. \] In logistic regression, \(p_i=\operatorname{logit}^{-1}(\eta_i)\). If the coefficient vector is estimated by \(\hat{\beta}\), the fitted probability is \(\hat p_i=\operatorname{logit}^{-1}(x_i^\mathsf{T}\hat{\beta})\).

The transformation is not an extra model assumption separate from the logit specification. It follows by solving that specification for \(p_i\). The formula also makes clear that the probability depends on the predictor through a nonlinear transformation, even though the predictor itself is linear in the covariates and coefficients.

Deriving the Inverse-Logit

Start with a probability \(p\) strictly between zero and one and suppose its logit equals a given predictor \(\eta\). Exponentiating both sides of the logit equation and then isolating \(p\) gives the required transformation.

$$ \begin{aligned} \eta &= \log\!\left(\frac{p}{1-p}\right)\\ \exp(\eta) &= \frac{p}{1-p}\\ \exp(\eta)(1-p) &= p\\ \exp(\eta) &= p\bigl(1+\exp(\eta)\bigr)\\ p &= \frac{\exp(\eta)}{1+\exp(\eta)}. \end{aligned} $$

Each step is valid because \(0<p<1\) makes the logit defined, and \(1+\exp(\eta)>0\) for every real \(\eta\). Conversely, the final expression defines a number strictly between zero and one for any finite real \(\eta\). Thus the formula works in both directions: every allowed probability has a real logit, and every real predictor gives an allowed probability.

Worked Example: Inverting a Logit of \(\log(3)\)

Suppose a linear predictor has the value \(\eta=\log(3)\). Find the probability specified by the logistic model.

Substitute \(\log(3)\) into the inverse-logit formula. Since \(\exp(\log(3))=3\),

$$ p=\frac{\exp(\log(3))}{1+\exp(\log(3))} =\frac{3}{1+3} =\frac{3}{4} =0.75. $$

The result is a valid probability, and applying the logit checks the calculation: \(\log\!\left(\frac{0.75}{1-0.75}\right)=\log(3)=\eta\).

Range, Limits, and Monotonicity

The inverse-logit’s range and direction of change follow directly from its formula. These properties explain why a linear predictor can range across the entire real line without producing an impossible probability.

Theorem: The function \(g(\eta)=\exp(\eta)/(1+\exp(\eta))\) is a strictly increasing bijection from \(\mathbb{R}\) to \((0,1)\). Its limits are \(0\) as \(\eta\to-\infty\) and \(1\) as \(\eta\to+\infty\).

Proof. For any finite \(\eta\), \(\exp(\eta)>0\), and the denominator \(1+\exp(\eta)\) is larger than the numerator. Therefore \(0<g(\eta)<1\). Differentiating gives

$$ g'(\eta) =\frac{\exp(\eta)(1+\exp(\eta))-\exp(\eta)\exp(\eta)} {(1+\exp(\eta))^2} =\frac{\exp(\eta)}{(1+\exp(\eta))^2} =g(\eta)\bigl(1-g(\eta)\bigr)>0. $$

The positive derivative proves strict increase. For the limits, as \(\eta\to-\infty\), \(\exp(\eta)\to0\), so \(g(\eta)\to0\). As \(\eta\to+\infty\), divide numerator and denominator by \(\exp(\eta)\) to obtain \(g(\eta)=1/(1+\exp(-\eta))\to1\). Hence the function approaches the endpoints but never attains either at a finite predictor.

To see that every probability \(p\in(0,1)\) occurs, set \(\eta=\log(p/(1-p))\). Substitution into \(g\) returns \(p\), as shown by the derivation above. This proves that the range is the whole open interval \((0,1)\), and strict increase ensures that no two distinct predictors give the same probability. \(\square\)

The derivative also describes sensitivity: \(g'(\eta)=p(1-p)\), where \(p=g(\eta)\). Since \(p(1-p)\leq1/4\), with equality at \(p=1/2\), the probability changes most rapidly around \(\eta=0\). Far into either tail, the derivative is small and changing the predictor by a fixed amount changes the probability less.

Calculating Fitted Probabilities

In a model with covariates \(x_{i1},\ldots,x_{ik}\), the linear predictor commonly has the form \(\eta_i=\beta_0+\beta_1x_{i1}+\cdots+\beta_kx_{ik}\). A fitted probability is calculated in two steps: first evaluate this linear combination using the estimated coefficients, and then apply the inverse-logit. Keep these steps distinct; the predictor is not itself a probability.

Worked Example: Substituting Covariates and Coefficients

Consider the fitted linear predictor \(\hat\eta=-1.1+0.6x_1-0.2x_2\). For an observation with \(x_1=2\) and \(x_2=1\), calculate the fitted probability.

First evaluate the predictor:

$$ \hat\eta=-1.1+0.6(2)-0.2(1)=-1.1+1.2-0.2=-0.1. $$

Now apply the inverse-logit. Here the predictor is negative, so the equivalent form using \(\exp(\hat\eta)\) is convenient:

$$ \hat p =\frac{\exp(-0.1)}{1+\exp(-0.1)} \approx\frac{0.904837}{1.904837} \approx0.475021. $$

Thus the model’s fitted probability for this observation is approximately \(0.475\). The answer is not \(-0.1\): that number is the fitted linear predictor, which can be negative, not a probability.

For any finite estimated coefficients and finite covariate values, the calculated predictor is finite and its fitted probability is strictly between zero and one. This is a mathematical property of the transformation, not a guarantee that the fitted probability is close to the event frequency for every particular observation.

Reliable Numerical Evaluation

The two algebraically equivalent expressions for the inverse-logit behave differently in computer arithmetic. Directly evaluating \(\exp(\eta)/(1+\exp(\eta))\) for a very large positive \(\eta\) can overflow, even though the mathematical result is close to one. Rewriting the expression gives a stable choice for either sign.

Computational rule: If \(\eta\geq0\), evaluate \(g(\eta)=1/(1+\exp(-\eta))\). If \(\eta<0\), evaluate \(g(\eta)=\exp(\eta)/(1+\exp(\eta))\). In each case the exponential has a nonpositive argument, avoiding exponentiation of a large positive number.

These forms are algebraically identical to the inverse-logit. For the first, divide the numerator and denominator of \(\exp(\eta)/(1+\exp(\eta))\) by \(\exp(\eta)\). For the second, use the original expression directly. The sign rule selects the form whose exponential is no larger than one.

Worked Example: Large Positive and Negative Predictors

Calculate fitted probabilities for predictors \(\eta=8\) and \(\eta=-8\), using the stable form in each case. Since \(\exp(-8)\approx0.000335463\), for the positive predictor use

$$ g(8)=\frac{1}{1+\exp(-8)} \approx\frac{1}{1.000335463} \approx0.999664650. $$

For the negative predictor, use the exponential of \(-8\) in the numerator:

$$ g(-8)=\frac{\exp(-8)}{1+\exp(-8)} \approx\frac{0.000335463}{1.000335463} \approx0.000335350. $$

As a check, \(g(-8)=1-g(8)\), because replacing \(\eta\) by \(-\eta\) complements the inverse-logit probability. The two results sum to approximately \(1.000000000\), up to rounding.

Common Mistakes and Why the Transformation Matters

  • Treating the predictor as a probability. A predictor such as \(-0.1\) is not a negative probability. Apply the inverse-logit to obtain \(\hat p\approx0.475\).
  • Assuming the output can equal zero or one. For every finite predictor, the output lies strictly inside \((0,1)\). Values near zero or one can occur, but the exact endpoints are limits.
  • Using the unstable expression for the wrong sign. For a positive predictor, computing \(\exp(\eta)\) may overflow; use \(1/(1+\exp(-\eta))\). For a negative predictor, use \(\exp(\eta)/(1+\exp(\eta))\), not a form that exponentiates \(-\eta\).
  • Rounding too early. Calculate the predictor using the available coefficient precision, apply the transformation, and round the final probability. Rounding intermediate values can change the reported result.

The inverse-logit is the step that translates a model’s linear scale into the probability scale needed to describe a binary outcome. Its strict range ensures valid probabilities, its monotonicity preserves the ordering of predictor values, and its stable computational forms make even extreme predictions practical to evaluate.

Check Your Understanding

Use the definition and properties above to answer the following.

  1. Solve \(\eta=\log(p/(1-p))\) for \(p\), showing the algebraic steps.
  2. Why can no finite linear predictor produce a fitted probability exactly equal to zero or one?
  3. For \(\eta=\log(2)\), calculate the inverse-logit probability and verify it by applying the logit.
  4. A fitted predictor is \(-0.4+0.3(2)\). Calculate the predictor first and then the fitted probability, showing the numerical evaluation.
  5. Which stable expression should be used for \(\eta=6\), and why is it preferable to the direct expression?
Clinical Biostats