liveBook · Manning

Linear component

As explained in Grokking Statistics

The linear component of a logistic function is the linear predictor whose value equals the outcome's log-odds.

In a logistic function, the linear component is the expression β0 + β1x inside the exponent. Its value equals the outcome’s log-odds: the logarithm of odds calculated from probability. This turns the S-shaped probability curve into a straight-line quantity that is easier to compare. section 8.4

Predicting a toddler meltdown

Using β0 = -7.0587, β1 = 2.2047, and x = 4 hours, the logistic function gives a meltdown probability of about 0.8532. That probability corresponds to odds of 5.813 to 1. Taking the natural logarithm of those odds produces the same value as β0 + β1x. When the linear component reaches zero, the logistic probability is 0.5. section 8.4

import math

def logistic(x, b0, b1):
   return 1.0 / (1.0 + math.exp(-(b0 + b1*x)))

b0 = -7.0587 #1
b1 = 2.2047 #2
x = 4 #3

p = logistic(x, b0, b1) #4
print(f"P({x}):", p) #4

odds = p / (1 - p) #5
print(f"O({x}):", odds) #5

log_odds = math.log(odds) #6
print(f"log(O({x})):", log_odds) #6

linear_fx_log_odds = b0 + b1*x #7
print(f"Linear Function Log-Odds:", linear_fx_log_odds) #7

Run the Python calculation to compare probability, odds, log-odds, and the linear component for one x-value. section 8.4

How Grokking Statistics covers it

How deep it goes
Defines the linear component, demonstrates its equality with log-odds, and stops short of a formal derivation.
Examples
Uses toddler meltdown probabilities at four and six hours, with Python calculations for probability and odds.
What it assumes
Assumes probability-to-odds conversion and natural logarithms while briefly reconnecting those ideas to logistic regression.
What you can do after
Apply it via Python to calculate and interpret probability, odds, log-odds, and the linear component.
How it connects
Links logistic regression with logistic functions, probability, odds, log-odds, and odds ratios.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Grokking Statistics. The section links point to the parts of the book it draws on.