Tutorials › Marginal Structural Models › Calibrating Predicted Treatment Probabilities

Inverse Probability of Treatment Weights · Tutorial 114 of 501

Calibrating Predicted Treatment Probabilities

Learn to recalibrate treatment probability predictions, calculate the resulting inverse weights, and distinguish improved calibration from a valid treatment model.

Advanced 11 min read

What You'll Learn

  • Define calibration for predicted probabilities of binary treatment.
  • Apply calibration-in-the-large and logistic recalibration to treatment predictions.
  • Calculate how recalibrated probabilities change treated and control inverse weights.
  • Prove what an intercept recalibration guarantees in its fitting sample.
  • Diagnose overfitting, poor overlap, and subgroup miscalibration after recalibration.
  • Distinguish calibration from correct adjustment for confounding.

Why Calibrate Treatment Probabilities?

Inverse probability of treatment weights use predicted treatment probabilities in their denominators. For a binary treatment, a small predicted probability for a treated person produces a large weight; a probability near one for a control does the same. This makes probability errors consequential: a prediction can look reasonable overall yet create unstable weights in the observations whose treatment was unlikely under the fitted model.

Calibration is one way to assess and, when appropriate, adjust the scale of predicted probabilities. It asks whether events occur at approximately the predicted rate among observations receiving similar predictions. It does not, by itself, establish that the treatment model has adequately accounted for confounding. The distinction matters: a recalibration can improve agreement between predictions and observed treatment frequencies while leaving important covariate patterns unrepresented.

Definition: Let \(A_i\in\{0,1\}\) be the treatment received by individual \(i\), and let \(q_i\in(0,1)\) be a predicted probability of treatment. The predictions are calibrated if, conditional on the prediction \(Q=q\), the treatment frequency agrees with that prediction: \(P(A=1\mid Q=q)=q\), for values of \(q\) where this conditional probability is defined. In a finite sample, calibration is assessed approximately, often by comparing average predictions with observed treatment proportions in groups of predictions.

For clarity, the un-stabilized inverse probability weight for a binary treatment is

$$ w_i(q_i)=\frac{A_i}{q_i}+\frac{1-A_i}{1-q_i}. $$

Thus \(w_i=1/q_i\) for a treated individual and \(w_i=1/(1-q_i)\) for a control. Replacing \(q_i\) by a recalibrated value changes the denominator directly. All such calculations require probabilities strictly between zero and one. In a causal analysis, the usual identification assumptions, including consistency, no unmeasured confounding given the modeled covariates, and positivity, remain necessary. Calibration is not a substitute for them.

Calibration Methods and Their Meaning

A simple diagnostic groups predictions into bins and compares the average prediction in each bin with the observed treatment proportion. If a bin contains \(m\) individuals, its average prediction is \(\bar q\), and \(r\) of them received treatment, the observed proportion is \(r/m\). A difference between these values signals calibration error at that range of predictions. The binning is only a summary: results can depend on the number and boundaries of bins, and a small bin can have a noisy observed proportion.

A smooth alternative is logistic recalibration. Given original predictions \(q_i\), fit the calibration model

$$ \operatorname{logit}\{P(A_i=1\mid q_i)\} =\alpha+\beta\operatorname{logit}(q_i), \qquad \operatorname{logit}(u)=\log\!\left(\frac{u}{1-u}\right). $$

The fitted recalibrated probability is \(\hat q_i^{\,\mathrm{cal}}=\operatorname{expit}\{\hat\alpha+\hat\beta\operatorname{logit}(q_i)\}\), where \(\operatorname{expit}(x)=1/(1+\exp(-x))\). Ideal calibration in this model corresponds to \(\alpha=0\) and \(\beta=1\). Calibration-in-the-large fixes \(\beta=1\) and adjusts only the intercept; it shifts the predictions on the log-odds scale. A fitted slope below one pulls predictions toward the middle, while a slope above one spreads them farther apart, if the intercept is held at zero.

These procedures require observed treatment indicators paired with predictions, and the calibration sample must represent the setting where the predictions will be used. A recalibration estimated and evaluated on the same observations can appear better simply because it has adapted to their treatment outcomes. Independent validation data or cross-fitting can reduce this optimism. Calibration estimates can also be unstable when treatment outcomes are sparse or predictions lie near zero or one.

Worked Example: Correcting Two Groups of Predictions

Suppose 20 individuals have predictions in two groups. Ten have \(q_i=0.20\), of whom 4 received treatment; ten have \(q_i=0.80\), of whom 6 received treatment. A bin-based recalibration maps each group's prediction to its observed treatment proportion.

For the first group, the observed proportion is \(4/10=0.40\), so the recalibrated prediction is \(0.40\). For the second group it is \(6/10=0.60\), so the recalibrated prediction is \(0.60\). In each bin, the recalibrated average prediction now equals the observed proportion.

For a treated person in the first group, the original weight is \(1/0.20=5\), while the recalibrated weight is \(1/0.40=2.5\). For a control in that group, the weights are \(1/0.80=1.25\) and \(1/0.60\approx1.67\), respectively. In the second group, a treated person's weight changes from \(1/0.80=1.25\) to \(1/0.60\approx1.67\); a control's changes from \(1/0.20=5\) to \(1/0.40=2.5\).

The bin adjustment reduces the most extreme weights in these data, but it does not guarantee that weights will be less variable in every sample. Nor does exact agreement within these two bins show that predictions are calibrated within finer covariate subgroups.

How Recalibration Changes Weights

The direction of weight changes can be determined without fitting a particular calibration model. Suppose an intercept adjustment adds \(\alpha\) to every logit, and write \(c=\exp(\alpha)>0\). Its probability mapping is

$$ g_c(q)=\operatorname{expit}\{\operatorname{logit}(q)+\alpha\} =\frac{cq}{1-q+cq}. $$

This mapping multiplies the odds by \(c\). The next result gives the corresponding changes in the two treatment-specific weights.

Result: For \(0<q<1\), the recalibrated probability satisfies \(g_c(q)-q=\dfrac{(c-1)q(1-q)}{1-q+cq}\). Consequently, if \(c>1\), then \(g_c(q)>q\): the treated weight \(1/g_c(q)\) decreases and the control weight \(1/\{1-g_c(q)\}\) increases. If \(0<c<1\), these directions reverse. If \(c=1\), neither weight changes.

To verify the probability comparison, subtract \(q\) from the displayed expression for \(g_c(q)\):

$$ g_c(q)-q =\frac{cq-q(1-q+cq)}{1-q+cq} =\frac{(c-1)q(1-q)}{1-q+cq}. $$

The denominator and \(q(1-q)\) are positive, so the sign is the sign of \(c-1\). Since reciprocation reverses the ordering of positive numbers, \(g_c(q)>q\) implies \(1/g_c(q)<1/q\). It also implies \(1-g_c(q)<1-q\), and hence \(1/\{1-g_c(q)\}>1/(1-q)\). The reverse inequalities hold when \(c<1\). This establishes the result. \(\square\)

An intercept shift therefore does not simply “shrink all weights.” It lowers treated weights while raising control weights when it raises all probabilities. Whether the overall weight distribution becomes more or less dispersed depends on which treatment groups have which predictions and how much the shift changes them.

Worked Example: An Intercept Shift and Individual Weights

Suppose a calibration assessment supports an intercept adjustment \(\alpha=\log(2)\), so the predicted odds are doubled. For original probabilities \(0.20\), \(0.50\), and \(0.80\), calculate the adjusted probabilities.

At \(q=0.20\), the odds are \(0.20/0.80=0.25\). Doubling gives odds \(0.50\), which corresponds to probability \(0.50/(1+0.50)=1/3\). At \(q=0.50\), the odds \(1\) become \(2\), giving probability \(2/3\). At \(q=0.80\), the odds \(4\) become \(8\), giving probability \(8/9\).

A treated individual with original prediction \(0.20\) has weight \(1/0.20=5\), changing to \(1/(1/3)=3\). A control with original prediction \(0.80\) has weight \(1/(1-0.80)=5\), changing to \(1/(1-8/9)=9\). The treated weight falls while the control weight rises, as the result predicts. The adjustment has not made every weight smaller; in this case it has made one of these two weights substantially larger.

A slope adjustment can change weights differently across the prediction range. For instance, with \(\alpha=0\) and \(\beta=0.5\), logits are halved. A probability of \(0.25\) has odds \(1/3\); after the adjustment the odds are \(1/\sqrt{3}\), giving probability \(1/(1+\sqrt{3})\approx0.366\). A probability of \(0.75\) becomes \(1/(1+1/\sqrt{3})\approx0.634\). A treated person's weight at \(q=0.25\) therefore changes from \(4\) to approximately \(1/0.366=2.73\). A control's weight at \(q=0.75\) changes from \(4\) to approximately \(1/(1-0.634)=2.73\). Here the slope adjustment pulls both predictions toward \(0.5\) and reduces these example weights.

What Intercept Calibration Guarantees

Calibration-in-the-large has a precise in-sample property when its intercept is estimated by logistic likelihood with the original predictions as an offset. Let \(q_i\in(0,1)\) be fixed predictions and define \(q_i(\alpha)=\operatorname{expit}\{\operatorname{logit}(q_i)+\alpha\}\). Assume the sample contains at least one treated and one control individual. If a finite maximum-likelihood estimate \(\hat\alpha\) is used, then the average recalibrated prediction equals the observed treatment proportion.

Result: Under the conditions above, $$ \frac{1}{n}\sum_{i=1}^n q_i(\hat\alpha) =\frac{1}{n}\sum_{i=1}^n A_i. $$ This is an in-sample equality for the overall treatment frequency. It does not imply calibration within covariate strata or validate the causal treatment model.

For a complete derivation, the log-likelihood as a function of the intercept is

$$ \ell(\alpha)=\sum_{i=1}^n \left[A_i\log q_i(\alpha)+(1-A_i)\log\{1-q_i(\alpha)\}\right]. $$

Since the derivative of \(\operatorname{logit}(q_i)+\alpha\) with respect to \(\alpha\) is one, differentiation gives

$$ \ell'(\alpha)=\sum_{i=1}^n\{A_i-q_i(\alpha)\}, \qquad \ell''(\alpha)=-\sum_{i=1}^n q_i(\alpha)\{1-q_i(\alpha)\}<0. $$

The likelihood is strictly concave. As \(\alpha\) tends to negative infinity, every \(q_i(\alpha)\) tends to zero, so \(\ell'(\alpha)\) tends to \(\sum_i A_i>0\). As \(\alpha\) tends to positive infinity, every \(q_i(\alpha)\) tends to one, so \(\ell'(\alpha)\) tends to \(\sum_i A_i-n<0\). Continuity gives a root, and strict concavity makes it unique. At the maximum, \(\ell'(\hat\alpha)=0\), so \(\sum_i A_i=\sum_i q_i(\hat\alpha)\). Dividing by \(n\) proves the equality. If all individuals have the same treatment value, there is no finite intercept maximum; the fitted intercept diverges toward a boundary. \(\square\)

This guarantee is deliberately limited. A single intercept can match the overall treatment rate while predictions are too low for one covariate group and too high for another. A calibration plot, subgroup checks, and weight diagnostics are therefore still needed. In particular, inspect extreme weights and the effective sample size, commonly summarized for weights \(w_i\) as \((\sum_i w_i)^2/\sum_i w_i^2\). A small value relative to \(n\) signals that a few observations dominate weighted summaries.

Choosing and Checking a Calibration Approach

ApproachWhat it adjustsMain caution
Bin-based calibrationObserved treatment frequency within prediction groupsResults depend on bin choices and can be noisy in small bins
Logistic intercept recalibrationOverall level of predicted probabilities on the log-odds scaleCan match the overall rate while missing subgroup errors
Logistic slope and intercept recalibrationOverall level and spread of predictionsMay overfit when the calibration sample is small
Changing the treatment modelThe relationship between measured covariates and treatmentRequires modeling decisions; calibration alone cannot make it unnecessary

Calibration is most useful when predictions are systematically too high or too low, or when their spread does not match observed treatment patterns. It is less persuasive when apparent errors are based on a few observations, when the calibration sample differs from the target population, or when a single summary hides substantial subgroup differences. Flexible binning or recalibration can itself overfit; predictions should be checked on data not used to fit the adjustment whenever possible.

A common mistake is to reason, “The recalibrated predictions match the observed treatment proportion, so the propensity model is correct and the weights remove confounding.” The correction is that calibration assesses agreement between predicted probabilities and treatment frequencies at the resolution being checked. Overall agreement does not guarantee agreement within covariate patterns relevant to treatment assignment, and neither agreement nor large weights can test the absence of unmeasured confounding. Compare calibration diagnostics with substantive knowledge of the treatment process, covariate coverage, and the resulting weight distribution.

Calibration is a post-processing option, not an automatic repair. Alternatives include revisiting the original treatment model, using a different probability estimator, or retaining the original predictions if the proposed recalibration is unsupported or unstable. Truncating extreme weights is a separate intervention: it directly modifies weights and can introduce bias, whereas calibration modifies predicted probabilities and then recomputes weights. Neither operation should be described as correcting all model misspecification.

Check Your Understanding

Answer each question, then compare your work with the solutions.

  1. In a group of 20 individuals with prediction \(q=0.30\), 8 received treatment. What is the bin-based recalibrated probability, and what happens to the weight of a treated individual with this prediction?
  2. A calibration-in-the-large adjustment has \(\alpha=-\log(2)\). Does it raise or lower predicted probabilities? Which treatment group's individual weights move upward?
  3. Why does an intercept-only recalibration that matches the overall treatment proportion not establish calibration within every covariate subgroup?
  4. Give one reason to assess recalibration on data other than the data used to fit it.

Solutions. (1) The observed proportion is \(8/20=0.40\), so the recalibrated probability is \(0.40\). A treated individual's weight changes from \(1/0.30=3.33\) to \(1/0.40=2.5\). (2) Here \(c=\exp(\alpha)=1/2<1\), so probabilities decrease. Treated weights \(1/q\) increase, while control weights \(1/(1-q)\) decrease. (3) Matching the overall mean imposes one equality on the whole sample; errors in different subgroups can cancel in that average. (4) Reusing the fitting data can make recalibration appear better because it was adjusted using those same observed treatment outcomes; independent evaluation helps reveal that optimism.

Clinical Biostats