Logistic Regression — Se Yoon Lee, Ph.D.

Explore binary outcomes, odds and log odds, maximum-likelihood fitting, coefficient interpretation, prediction, calibration, and the two causal-inference roles of logistic regression: outcome modeling and propensity-score estimation.

Core map: η=xTβp=11+eηYBernoulli(p)
GRADUATE-LEVEL • SELF-CONTAINED • INLINE SVG

Mathematical formulation

Move from a binary conditional mean to odds, maximum likelihood, Wald inference, and causal nuisance functions.

NATIVE MATHML
Bernoulli likelihood
L(β)=i=1npiYi(1pi)1Yi,pi=expit(xiTβ)

Score and information

U(β)=XT(Yp)I(β)=XTWX,Wii=pi(1pi)

Newton–Raphson / IRLS

β(k+1)=β(k)+{XTWX}1XT(Yp)
Conditional odds-ratio interpretation
odds{Y=1|Xj+1,Xj}odds{Y=1|Xj,Xj}=exp(βj)

Probability change is not constant

Δp=expit(η+βj)expit(η)

The same odds ratio can correspond to very different risk differences at different baseline risks.

Odds ratio is not risk ratio

RR(p,OR)=OR1p+OR·p
Wald inference
β^N{β,(XTW^X)1}

Coefficient interval

β^j±1.96SE^(β^j)

Odds-ratio interval

exp[β^j±1.96SE^(β^j)]
Two causal-inference nuisance functions
e(X)=P(T=1|X),m(t,X)=P(Y=1|T=t,X)

Outcome-regression standardization

ψ^t=1ni=1nm^(t,Xi)

ATE inverse-probability weight

wi=Tie^(Xi)+1Ti1e^(Xi)

1. Probability, odds, and log-odds map

The logistic function maps an unbounded linear predictor to a valid probability.

expit(η)current subject

2. Current subject: additive log-odds contributions

Term contributions add on the η scale; the final inverse-logit transformation is nonlinear.

3. Binary outcomes and fitted CVD-risk curves

Validation outcomes remain 0 or 1; the fitted model estimates their conditional mean.

set T=0set T=1true DGP curvebands = 95% delta-method pointwise CI using the selected covariance
Empirical points are observed age-bin risks within the actual smoking groups. Fitted curves can be reference-profile curves or averages over a common covariate distribution.

4. Coefficients, standard errors, and conditional odds ratios

Click a row to update the coefficient-focused mathematical interpretation.

Termβ̂SEzpexp(β̂)95% exp(β) CI
Interpretation: exp(β̂) is a conditional odds ratio only for a meaningful one-unit covariate contrast with the remaining model terms held fixed. For the intercept it is baseline odds; for Age² it is a curvature parameter; and for Smoker × age it is a ratio of odds ratios.

5. Outcome logistic model → standardized marginal risks

Every target-cohort subject is predicted twice, once under T=0 and once under T=1.

6. Treatment logistic model → propensity scores

A separate logistic regression estimates e(X)=P(T=1|X) and reveals overlap and extreme weights.

High treatment-prediction accuracy is not the goal. For causal weighting, inspect overlap, balance, and the concentration of inverse-probability weights.
Lecture NHANES reference results and exports

One-predictor age model

Complete-case classroom sample: n=6,299; 646 CVD events. The lecture fit was β̂₀=−6.172 and β̂age=0.07247 per year.

QuantityLecture value
OR per year1.075
OR per 10 years2.064
Residual deviance3605.6
AIC3609.6

Multivariable outcome model and standardization

Term / estimandLecture value
Smoking conditional OR1.539
BMI OR per unit1.031
Income-ratio OR per unit0.833
Standardized risk T=08.53%
Standardized risk T=111.98%
Marginal RD3.45 pp
Marginal RR1.405