Tutorials › Marginal Structural Models › Estimating Binary Treatment Probabilities With Logistic Regression

Inverse Probability of Treatment Weights · Tutorial 83 of 501

Estimating Binary Treatment Probabilities With Logistic Regression

Learn how a fitted logistic treatment model produces inverse probability weights, what assumptions make those weights useful, and how to diagnose unstable estimates.

Advanced 13 min read

What You'll Learn

  • Define the propensity score for a one-time binary treatment and specify a logistic regression model.
  • Derive the likelihood and score equations used to fit the model.
  • Calculate unstabilized and stabilized inverse probability weights from fitted probabilities.
  • Prove how the true propensity score reweights treatment groups and identifies marginal potential-outcome means.
  • Diagnose poor overlap, extreme weights, and model misspecification.
  • Compare logistic propensity weighting with stratification and other treatment-probability models.

From Treatment Probabilities to Weights

For a one-time binary treatment, each individual either receives treatment or does not. The inverse probability of treatment weight (IPTW) gives greater weight to individuals whose observed treatment was less probable given their measured covariates. The goal is to create a weighted population in which treatment assignment is no longer associated with those covariates, provided the treatment probabilities are adequately estimated and the necessary causal assumptions hold.

Let \(A_i\in\{0,1\}\) denote the treatment received by individual \(i\), and let \(\mathbf L_i\) be a vector of measured covariates observed before treatment. The propensity score is the conditional probability of treatment given these covariates. Logistic regression is one parametric method for estimating it.

Definition: The propensity score is \(e(\mathbf L)=P(A=1\mid \mathbf L)\). A logistic treatment model specifies $$ \operatorname{logit}\{e(\mathbf L_i)\}=\beta_0+\boldsymbol\beta^{\mathsf T}\mathbf L_i, \qquad \operatorname{logit}(q)=\log\left(\frac{q}{1-q}\right). $$ After estimating the coefficients, the fitted probability is $$ \hat e_i=\frac{\exp(\hat\beta_0+\hat{\boldsymbol\beta}^{\mathsf T}\mathbf L_i)} {1+\exp(\hat\beta_0+\hat{\boldsymbol\beta}^{\mathsf T}\mathbf L_i)}. $$

The covariates in this model should be measured before treatment. For causal interpretation, the central assumptions are consistency, conditional exchangeability, and positivity. Consistency means that the observed outcome equals the potential outcome under the treatment actually received. Conditional exchangeability means \(A\) is independent of \((Y^0,Y^1)\) given \(\mathbf L\), where \(Y^a\) is the outcome that would occur under treatment level \(a\). Positivity means \(0<e(\mathbf L)<1\) for covariate patterns in the target population. In practice, estimation also depends on whether the chosen logistic model represents the conditional treatment probability well enough.

Fitting the Logistic Model and Constructing Weights

For independent observations, the Bernoulli likelihood for the one-time treatment model is the product of the probabilities assigned to the observed treatment values. Its log-likelihood is $$ \ell(\boldsymbol\beta)=\sum_{i=1}^n \left[A_i\log\{e_i(\boldsymbol\beta)\}+(1-A_i)\log\{1-e_i(\boldsymbol\beta)\}\right], $$ where \(e_i(\boldsymbol\beta)\) is the logistic probability implied by the model. Maximizing this function gives the maximum likelihood estimate when a finite maximizer exists. With \(\mathbf Z_i=(1,\mathbf L_i^{\mathsf T})^{\mathsf T}\), differentiation gives the score $$ \frac{\partial\ell(\boldsymbol\beta)}{\partial\boldsymbol\beta} =\sum_{i=1}^n\{A_i-e_i(\boldsymbol\beta)\}\mathbf Z_i. $$ Thus, at a finite maximum, the score is zero. Complete or quasi-complete separation can prevent a finite maximum; a numerical fitting routine may then report very large coefficients or fail to converge.

For an individual with observed treatment \(A_i\), the unstabilized weight is the inverse of the fitted probability of receiving that observed treatment. A stabilized weight multiplies that inverse probability by the marginal probability of the observed treatment. In the one-time setting, the usual estimated numerator is the sample treatment proportion \(\hat p=n^{-1}\sum_i A_i\).

Definition: The estimated unstabilized and stabilized weights are $$ \hat W_i= \frac{A_i}{\hat e_i}+\frac{1-A_i}{1-\hat e_i}, \qquad \hat W_i^{\,\mathrm{stab}}= \frac{A_i\hat p}{\hat e_i}+ \frac{(1-A_i)(1-\hat p)}{1-\hat e_i}. $$ For a treated individual, these reduce to \(1/\hat e_i\) and \(\hat p/\hat e_i\); for an untreated individual, they reduce to \(1/(1-\hat e_i)\) and \((1-\hat p)/(1-\hat e_i)\).

The numerator in the stabilized weight can reduce weight variability while retaining the treatment-group covariate balancing property in the population. Stabilization does not repair poor overlap or an incorrectly specified denominator model. The estimated weights are also not themselves treatment effects: they are used in a subsequent weighted analysis.

Worked Example: Calculating Weights From a Logistic Model

Suppose a fitted model has linear predictor \(\hat\eta=-1+0.8L\), where \(L\) is a binary baseline covariate. For an individual with \(L=1\), the fitted logit is \(-1+0.8=-0.2\), so $$ \hat e=\frac{1}{1+\exp(0.2)}\approx 0.450166. $$

If this individual is treated, the unstabilized weight is \(1/\hat e\approx 2.2214\). If the individual is untreated, the weight is \(1/(1-\hat e)\approx 1.81873\), which rounds to 1.819. The calculation uses the unrounded fitted probability; rounding \(0.450166\) to \(0.450\) first would slightly change the result.

If the sample treatment proportion is \(\hat p=0.4\), the stabilized weights are \(0.4/0.450166\approx 0.88856\) for a treated individual and \(0.6/(1-0.450166)\approx 1.09124\) for an untreated individual. The numerator differs by treatment group, so stabilization does not mean every weight is less than one.

Why the True Weights Work

The key weighting identity follows directly from conditioning on \(\mathbf L\). It describes weights formed from the true propensity score, not automatically the weights formed from a fitted model.

Theorem: Suppose \(0<e(\mathbf L)<1\) almost surely. For any integrable function \(h(\mathbf L)\), $$ E\left[\frac{A}{e(\mathbf L)}h(\mathbf L)\right]=E[h(\mathbf L)], \qquad E\left[\frac{1-A}{1-e(\mathbf L)}h(\mathbf L)\right]=E[h(\mathbf L)]. $$ Consequently, the treated and untreated groups have the same covariate distribution after weighting by their respective inverse treatment probabilities.

Proof. By iterated expectation and the definition \(E[A\mid\mathbf L]=e(\mathbf L)\), $$ E\left[\frac{A}{e(\mathbf L)}h(\mathbf L)\mid\mathbf L\right] =\frac{h(\mathbf L)}{e(\mathbf L)}E[A\mid\mathbf L] =h(\mathbf L). $$ Taking expectations gives the first identity. Since \(E[1-A\mid\mathbf L]=1-e(\mathbf L)\), $$ E\left[\frac{1-A}{1-e(\mathbf L)}h(\mathbf L)\mid\mathbf L\right] =\frac{h(\mathbf L)}{1-e(\mathbf L)}\{1-e(\mathbf L)\} =h(\mathbf L). $$ Taking expectations gives the second identity. Taking \(h=1\) shows that each group’s expected total weight is one; taking general \(h\) shows their normalized weighted covariate distributions match the marginal distribution of \(\mathbf L\). \(\square\)

The same calculation connects weighting to causal outcomes. Under consistency, conditional exchangeability, positivity, and integrability of the potential outcomes, $$ E\left[\frac{AY}{e(\mathbf L)}\right]=E[Y^1], \qquad E\left[\frac{(1-A)Y}{1-e(\mathbf L)}\right]=E[Y^0]. $$ For the treated expression, consistency gives \(AY=AY^1\). Conditional on \(\mathbf L\), exchangeability gives \(E[Y^1\mid A=1,\mathbf L]=E[Y^1\mid\mathbf L]\), and therefore $$ E\left[\frac{AY}{e(\mathbf L)}\mid\mathbf L\right] =\frac{1}{e(\mathbf L)}E[AY^1\mid\mathbf L] =E[Y^1\mid\mathbf L]. $$ Averaging over \(\mathbf L\) yields the first equality. Replacing \(A\) by \(1-A\) and \(Y^1\) by \(Y^0\) proves the second. Thus the difference of these population weighted means identifies the average treatment effect \(E[Y^1]-E[Y^0]\). With estimated probabilities, this result is an approximation whose quality depends on estimation, model specification, and overlap.

Worked Example: A Saturated Model With a Binary Covariate

Suppose there are 10 individuals with \(L=0\), of whom 2 are treated, and 10 with \(L=1\), of whom 6 are treated. A logistic regression with an intercept and \(L\) fits each group’s observed treatment rate exactly: \(\hat e(0)=2/10=0.2\) and \(\hat e(1)=6/10=0.6\). The coefficients are $$ \hat\beta_0=\log\left(\frac{0.2}{0.8}\right)=\log(0.25)\approx-1.3863, \qquad \hat\beta_1=\log\left(\frac{0.6}{0.4}\right)-\hat\beta_0 \approx 0.4055-(-1.3863)=1.7918. $$

For \(L=0\), a treated individual has weight \(1/0.2=5\), and an untreated individual has weight \(1/0.8=1.25\). The treated weighted total for this covariate group is \(2(5)=10\); the untreated weighted total is \(8(1.25)=10\).

For \(L=1\), the corresponding weights are \(1/0.6\approx1.6667\) and \(1/0.4=2.5\). The treated total is \(6(1.6667)\approx10\), and the untreated total is \(4(2.5)=10\). Thus each treatment group has the same weighted count in both covariate categories. This exact balance occurs here because the model fits the two observed group-specific treatment rates; it is not a guarantee of exact balance for every covariate under every fitted logistic model.

Worked Example: Diagnosing Near-Violation of Positivity

Suppose a fitted logistic model predicts \(\hat e=0.02\) for one covariate pattern and \(\hat e=0.98\) for another. Under the unstabilized rule, an actually treated individual in the first pattern receives weight \(1/0.02=50\), while an untreated individual there receives \(1/0.98\approx1.0204\). In the second pattern, the weights reverse: a treated individual receives \(1/0.98\approx1.0204\), and an untreated individual receives \(1/0.02=50\).

If \(\hat p=0.5\), the corresponding stabilized weights of 50 become \(0.5/0.02=25\); the other weights become \(0.5/0.98\approx0.5102\). Stabilization reduces these particular values but does not remove the underlying lack of overlap. The extreme weights signal that a small number of individuals can dominate a weighted analysis.

Diagnostics, Alternatives, and Limitations

A fitted probability model should be assessed as part of the weighting procedure, not only by whether its regression software converged. Useful checks include:

  • Inspect overlap: compare fitted probability distributions for treated and untreated individuals. If one group has probabilities near zero or one in covariate regions occupied by the other group, positivity may be weak.
  • Inspect the weights: report their range and upper quantiles, and check whether a few observations dominate. One summary is the effective sample size, \(\mathrm{ESS}=(\sum_i\hat W_i)^2/\sum_i\hat W_i^2\); a much smaller ESS than the original sample size indicates concentration of weight.
  • Check weighted covariate balance: compare covariate distributions between treatment groups before and after weighting. Good prediction of treatment is not the same as good covariate balance.
  • Check model adequacy: look for implausible fitted probabilities, convergence warnings, and poor calibration. Separation and omitted structure can make estimates unstable or misleading.

Logistic regression is a parametric approach: it gives a compact model and probabilities between zero and one, but its adequacy depends on the specified relationship between covariates and treatment. Stratification on the propensity score or on selected covariates is an alternative that can be transparent, but may leave residual imbalance within strata and can be difficult with many covariates. A different probability model, such as a probit model, changes the functional form but does not by itself solve confounding, lack of overlap, or misspecification. Regardless of approach, balance and support must be examined.

Truncating or capping extreme weights can reduce variance, but it changes the weighting procedure and may introduce bias; it does not create treatment support where none exists. If important confounders are unmeasured, weighting cannot balance them. If the logistic model is misspecified, fitted weights need not satisfy the population identities derived above. Finally, a finite-sample weighted analysis is not guaranteed to have exact balance merely because a logistic regression was fitted.

Common Mistake

A frequent error is to use \(1/\hat e_i\) for every individual. That is the correct unstabilized weight only when \(A_i=1\). For an untreated individual, the probability of the observed treatment is \(1-\hat e_i\), so the correct weight is \(1/(1-\hat e_i)\). Another error is to treat an extreme fitted probability as a minor numerical inconvenience: a probability near zero for a treated person produces a large weight and can make the estimate highly variable. Verify the treatment-specific formula first, then examine overlap and the resulting weight distribution.

Check Your Understanding

Answer each question, then compare with the solutions below.

  1. An untreated individual has fitted treatment probability \(0.25\). What is the unstabilized weight?
  2. State the positivity condition for a one-time binary treatment and explain why a fitted probability near zero can be concerning for a treated individual.
  3. For a treated individual with fitted probability \(0.4\) and sample treatment proportion \(0.3\), calculate the stabilized weight.
  4. Why does good prediction of treatment not, by itself, establish that a propensity model is suitable for weighting?

Solutions. (1) The probability of the observed untreated treatment is \(1-0.25=0.75\), so the weight is \(1/0.75=1.3333\). (2) Positivity requires \(0<e(\mathbf L)<1\) for covariate patterns in the target population. If a treated person has a fitted probability near zero, the inverse weight is large, making the estimate sensitive to that person and indicating weak overlap. (3) The stabilized treated weight is \(0.3/0.4=0.75\). (4) Prediction assesses how well treatment status is predicted, whereas weighting requires adequate covariate balance and support. A model may predict treatment well while producing poor balance or extreme weights.

Clinical Biostats