Why penalize a treatment-probability model?
A binary treatment model may include many baseline covariates, nonlinear terms, or interactions, while the observed treatment data contain relatively little information about some of those terms. In that setting, ordinary logistic regression can produce unstable coefficients and fitted probabilities close to zero or one. Ridge and lasso logistic regression add a penalty to the likelihood objective, discouraging large coefficients. The resulting probabilities can be less variable, but the penalty changes the fitted model: it is not a guarantee of correct treatment probabilities, adequate overlap, or valid causal conclusions.
Let \(A_i\in\{0,1\}\) denote treatment for unit \(i\), and let \(x_i\in\mathbb{R}^p\) be the covariate vector used to model treatment. Write the logistic model as \(p_i=P(A_i=1\mid x_i)=\operatorname{expit}(\alpha+x_i^\top\beta)\), where \(\operatorname{expit}(u)=1/(1+e^{-u})\). The vector \(x_i\) excludes the intercept; \(\alpha\) is the intercept and \(\beta\) contains the covariate coefficients.
The ridge penalty is \(\|\beta\|_2^2=\sum_{j=1}^p\beta_j^2\); it continuously discourages large coefficients. The lasso penalty is \(\|\beta\|_1=\sum_{j=1}^p|\beta_j|\); its nondifferentiability at zero allows some fitted coefficients to be exactly zero. Neither penalty acts directly on \(p_i\). The probabilities change because the estimated intercept and coefficients change.
The penalty must be defined with care. Covariates measured on different scales should generally be standardized before penalization, or otherwise put on a comparable scale, because a coefficient’s numerical size depends on its predictor’s units. The intercept is ordinarily left unpenalized. If a software implementation penalizes the intercept or uses a different scaling of the likelihood, its estimates and the interpretation of \(\lambda\) will differ from the definitions here.
What the penalty guarantees—and what it does not
One exact property follows from leaving the intercept unpenalized. Suppose a finite minimizer \((\hat\alpha,\hat\beta)\) exists. Differentiating the objective with respect to \(\alpha\) gives the same score equation for ridge and lasso, since neither penalty involves \(\alpha\).
Proof. The derivative of \(Q\) with respect to \(\alpha\) is \(n^{-1}\sum_i(p_i-A_i)\), because the derivative of \(\log(1+e^\eta)-A_i\eta\) with respect to \(\eta\) is \(\operatorname{expit}(\eta)-A_i\). At a finite minimum, the derivative with respect to the unconstrained intercept is zero. Neither penalty contributes to this derivative, so \(n^{-1}\sum_i(\hat p_i-A_i)=0\), which is the stated equality. \(\square\)
This equality is an in-sample average calibration property, not a claim that each subgroup is calibrated or that the model is correctly specified. For example, the average can match even when some fitted probabilities are far too high and others far too low. The result also relies on an intercept being included and unpenalized in the stated unweighted objective.
Worked Example: Ridge Shrinkage in Two Balanced Groups
Suppose there are 20 observations: 10 have \(x_i=1\), of whom 8 are treated, and 10 have \(x_i=-1\), of whom 2 are treated. Fit a logistic model with an intercept and one slope, using the ridge objective above with \(\lambda=0.5\).
The treatment proportions are \(0.8\) in the \(x=1\) group and \(0.2\) in the \(x=-1\) group. The data are symmetric: replacing \(x\) by \(-x\) also replaces the treatment proportion \(0.8\) by \(0.2\). The fitted intercept is therefore \(\hat\alpha=0\), and the fitted probabilities have the form \(\hat p_+=\operatorname{expit}(\hat\beta)\) and \(\hat p_-=\operatorname{expit}(-\hat\beta)=1-\hat p_+\).
With this symmetry, the ridge objective, up to terms not depending on \(\beta\), has derivative $$ \operatorname{expit}(\beta)-0.8+\lambda\beta. $$ Indeed, the two groups have equal size, and the average logistic score for the slope is \(\operatorname{expit}(\beta)-0.8\); the ridge penalty contributes \(\lambda\beta\). The minimizing slope therefore solves \(\operatorname{expit}(\beta)-0.8+0.5\beta=0\).
At \(\beta=0.40\), the left side is \(\operatorname{expit}(0.40)-0.8+0.20\approx0.5987-0.8+0.2=-0.0013\). At \(\beta=0.402\), it is approximately \(0.5992-0.8+0.201=0.0002\). The root is about \(0.402\), so the fitted probabilities are approximately \(0.599\) and \(0.401\). Without the penalty the slope is \(\log(0.8/0.2)=\log 4\approx1.386\), giving probabilities \(0.8\) and \(0.2\). Here ridge reduces the contrast between groups, moving these probabilities toward the overall treatment proportion, \(0.5\).
This is a special symmetric example, not a universal rule for each fitted probability. The intercept score result is visible here: the two ridge fitted probabilities average to \((0.599+0.401)/2=0.5\), equal to the observed treatment proportion.
Ridge shrinks the coefficient vector in a penalized optimization problem; it does not generally multiply every coefficient by the same factor. In a model with multiple, correlated predictors, estimates can change by different amounts and may even increase in absolute value for some coordinates as the penalty changes, while the overall penalized solution changes. Consequently, the linear predictor \(x_i^\top\hat\beta\) need not move toward zero for every observation. Since the expit function is increasing, a change in the linear predictor changes the probability in the same direction, but that direction need not be toward \(0.5\).
Worked Example: Lasso Can Set a Treatment Predictor to Zero
Consider 20 observations with 10 values \(x_i=1\) and 10 values \(x_i=-1\). In each group, let 5 of the 10 observations be treated. The observed treatment proportion is \(0.5\) in both groups. Fit a logistic model with an intercept and slope, using lasso with \(\lambda=0.06\).
At \(\alpha=0,\beta=0\), every fitted probability is \(0.5\), and the intercept score is zero. The slope score of the average negative log-likelihood is \(-n^{-1}\sum_i x_i(A_i-0.5)\). In the \(x=1\) group, the residuals \(A_i-0.5\) sum to zero; in the \(x=-1\) group, they also sum to zero. Therefore the slope score is zero. The lasso penalty cannot improve the objective by introducing a nonzero slope: for any \(\beta\), the likelihood part is minimized at zero slope in this balanced dataset, and \(\lambda|\beta|\) is minimized at \(\beta=0\). The fitted intercept and slope are thus zero, giving \(\hat p_i=0.5\) for every observation.
In less balanced data, the exact condition for a zero lasso coefficient is useful. At a fitted solution with \(\hat\beta_j=0\), the absolute value of the average likelihood score for that coefficient must be no greater than \(\lambda\). In this example the score is exactly zero, so the condition holds for \(\lambda=0.06\). A zero coefficient means that this predictor contributes nothing to the fitted linear predictor under this particular penalized fit; it does not establish that the predictor is causally irrelevant.
Derivation. The derivative of \(Q\) with respect to \(\beta_j\), evaluated at a candidate fit, is \(-n^{-1}\sum_i x_{ij}(A_i-\hat p_i)\). The subgradient of \(|\beta_j|\) is \(\{1\}\) when \(\beta_j>0\), \(\{-1\}\) when \(\beta_j<0\), and the interval \([-1,1]\) when \(\beta_j=0\). At zero, the optimality condition is that the likelihood derivative plus \(\lambda s\) equal zero for some \(s\in[-1,1]\). Such an \(s\) exists exactly when the absolute likelihood score is at most \(\lambda\), proving the stated condition. \(\square\)
At a full lasso solution, the same subgradient condition applies to every coefficient, jointly with the intercept score condition. The coordinatewise statement is a diagnostic for zero coefficients, not a license to optimize each coefficient independently while ignoring the others. The inclusion of correlated predictors can change which terms survive, so a selected subset may be unstable across samples or tuning values.
Worked Example: Smaller Coefficients Do Not Mean Every Probability Moves Toward One-Half
Consider two covariates and compare the coefficient vectors \(\beta=(2,0)\) and \(\tilde\beta=(1.2,0.8)\), with intercept zero. The second vector has smaller Euclidean norm: \(\|\beta\|_2=2\), whereas \(\|\tilde\beta\|_2=\sqrt{1.2^2+0.8^2}=\sqrt{2.08}\approx1.442\).
For an observation with \(x=(0,1)\), the first linear predictor is \(0\), giving probability \(\operatorname{expit}(0)=0.5\). The second is \(0.8\), giving probability \(\operatorname{expit}(0.8)\approx0.690\). Thus a coefficient vector with smaller overall norm can produce a fitted probability farther from \(0.5\) for a particular covariate pattern.
These vectors illustrate a geometric fact, not a claim that this pair must be the fitted path for a particular dataset. A penalty changes the estimated coefficient vector, and that change can alter its direction as well as its length. The practical conclusion is to inspect the fitted probabilities themselves rather than infer their behavior from coefficient magnitudes alone.
Choosing and checking a penalized model
The tuning parameter \(\lambda\) controls the strength of regularization. At \(\lambda=0\), either objective reduces to ordinary logistic maximum likelihood. Increasing \(\lambda\) generally reduces fitted coefficient complexity; for lasso it can set more coefficients to zero. In many applications, \(\lambda\) is selected by cross-validation or another prespecified prediction criterion. That selection targets predictive performance under the validation scheme; it does not automatically select the treatment model best suited to the causal estimand or guarantee that important confounders remain adequately represented.
Before interpreting the fitted probabilities, check the covariate coding and scaling, the treatment proportion, the fitted probability distribution within treatment groups, and whether the fit converged. Examine the path of coefficients and predicted probabilities over a reasonable range of \(\lambda\). For lasso, check whether selected covariates change substantially across folds or nearby tuning values. For either penalty, investigate probabilities near zero or one and the resulting distribution of inverse probability weights; penalization can reduce extreme fitted probabilities in some data, but does not guarantee that it does so for every observation or solve a lack of positivity.
The main alternatives answer somewhat different problems. Unpenalized logistic regression is appropriate when the model is estimable and its specification is defensible, but can be unstable with sparse data or separation. Firth logistic regression uses a likelihood correction rather than an \(L_1\) or \(L_2\) penalty and is a distinct approach to small-sample bias and separation. Ridge is often useful when many predictors should remain in the model but their estimates need stabilization. Lasso offers a sparse fitted model, but its selection can be sensitive to correlated predictors and it can omit variables that matter for confounding control. None of these estimation choices substitutes for sound covariate timing, a defensible treatment model, and diagnostics relevant to the estimated probabilities and weights.
Common pitfalls
- Assuming shrinkage guarantees overlap. A penalized logistic model still gives probabilities near zero or one when the data and covariate patterns support them. Inspect probabilities and weights rather than assuming the penalty has fixed positivity problems.
- Penalizing predictors on incomparable scales without adjustment. The penalty acts on coefficient magnitudes, which depend on measurement units. Standardize or otherwise define the scaling deliberately, and document how coefficients are interpreted.
- Reading a zero lasso coefficient as proof of no confounding role. It means the term is zero in the fitted penalized model at the chosen tuning value. It does not show that the variable is irrelevant to treatment assignment or causal adjustment.
- Assuming every fitted probability moves toward one-half. The intercept and multiple coefficients change together. Check the actual fitted probabilities, especially for covariate patterns that combine predictors in unusual ways.
Check Your Understanding
Answer each question, then check the concise solutions below.
- Why is the intercept ordinarily excluded from the ridge and lasso penalties in these models?
- A lasso fit has \(\hat\beta_j=0\). What inequality must the average likelihood score for that coefficient satisfy?
- In the symmetric two-group ridge example, why does the mean fitted probability remain \(0.5\) after shrinkage?
- Does a smaller ridge coefficient norm imply that every individual fitted probability is closer to \(0.5\)? Explain.
- Name one diagnostic that should still be performed after fitting a penalized treatment model.
Solutions. (1) Leaving the intercept unpenalized gives the intercept score equation, so the sample mean fitted probability equals the observed treatment proportion; penalizing it would remove that property. (2) It must satisfy \(\left|n^{-1}\sum_i x_{ij}(A_i-\hat p_i)\right|\leq\lambda\). (3) The two fitted probabilities are \(p\) and \(1-p\), so their equal-size average is \(0.5\), which is also the observed treatment proportion. (4) No. A coefficient vector can change direction as well as length, so a particular linear predictor can move away from zero. (5) For example, inspect fitted probabilities and resulting weights for extreme values, or check convergence and the stability of lasso-selected predictors across tuning values.