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
