Tutorials › Propensity Score Matching and Instrumental Variables › Worked Comparison of Flexible Propensity Estimators

The Balancing Property and Estimation · Tutorial 149 of 699

Worked Comparison of Flexible Propensity Estimators

Compare three flexible propensity estimators on the same hypothetical data, working through their predictions, calibration, and limitations.

Intermediate 11 min read

What You'll Learn

  • Define the treatment probability each flexible estimator is intended to estimate.
  • Compare generalized additive, random forest, and gradient-boosting predictions for the same covariate profiles.
  • Calculate grouped calibration gaps and a weighted absolute calibration summary.
  • Distinguish calibration from covariate balance and from causal validity.
  • Identify why cross-fitted evaluation and common tuning choices matter when comparing models.
  • Recognize when prediction differences signal a need for further investigation rather than a clear winner.

Why Compare Flexible Propensity Estimators?

A propensity score is the probability of receiving treatment conditional on observed covariates. Different model classes can estimate that probability in different ways: a generalized additive model can represent smooth, nonlinear covariate effects; a random forest can represent interactions through collections of trees; and gradient boosting can build a prediction function by adding trees in sequence. Their fitted probabilities need not agree, even when the models use the same data and covariates.

The practical question is not simply which method predicts treatment most accurately. Propensity scores are used in analyses that seek to adjust for observed covariates, so useful checks include whether probabilities are sensible, whether predictions are calibrated, and whether the estimated scores support adequate covariate balance in the intended analysis. Calibration is informative, but it is not a direct test of balance or of the assumptions needed for a causal interpretation.

Definition: Let \(T_i\) equal 1 if unit \(i\) receives treatment and 0 otherwise, and let \(X_i\) denote that unit’s observed covariates. The propensity score is \(e(X_i)=P(T_i=1\mid X_i)\). An estimated propensity score, written \(\hat e(X_i)\), is a model-based estimate of this conditional treatment probability.

The comparison below focuses on estimating these probabilities. For a causal interpretation, the analysis also needs substantive conditions such as consistency, conditional exchangeability given the measured covariates, and positivity. Estimating a score does not establish those conditions; in particular, no comparison of prediction algorithms can rule out unmeasured confounding.

Three Models, One Prediction Target

All three methods aim to estimate \(P(T=1\mid X)\), but impose different structures on how the covariates relate to treatment. In a logistic generalized additive model (GAM), a typical specification is

$$ \operatorname{logit}\{e(X_i)\}=\beta_0+\sum_{j=1}^{p} f_j(X_{ij}), \qquad \operatorname{logit}(u)=\log\left(\frac{u}{1-u}\right). $$

Here the \(f_j\) are smooth functions estimated from the data. This can capture nonlinear effects without requiring each effect to be a straight line on the log-odds scale. In this common additive form, however, covariate effects do not automatically interact; interactions need to be included if warranted. Smoothing choices also matter: a function that is too constrained can miss structure, while one that is too flexible can follow noise.

A random forest fits many trees using resampled data and, typically, randomly selected candidate predictors at tree splits. Its probability prediction aggregates the trees’ treatment-probability predictions. This approach can capture nonlinearities and interactions, but the result depends on choices such as tree depth, the number of candidate predictors, and the number of trees. Averaging can produce stable predictions, but does not guarantee good calibration.

Gradient boosting builds an additive sequence of trees, with later trees chosen to improve the current predictions under a specified loss function. For binary treatment, logistic loss is a common choice. The learning rate, tree depth, and number of boosting steps regulate how complex the fitted function becomes. Too little boosting can underfit; too much can fit idiosyncrasies in the training sample.

These brief descriptions identify the models being compared, not a universal specification for each. Different implementations and tuning choices can produce different predictions. For a fair comparison, use the same units, treatment definition, candidate covariates, and evaluation rows, and document the modeling and tuning choices. A single selected fit from each model class is a comparison of those fits, not proof that one entire model class is superior.

A Hypothetical Dataset and Three Sets of Predictions

Consider 12 hypothetical units. Before examining treatment, an analyst groups them into three prespecified covariate profiles: low, middle, and high treatment propensity based on observed covariate patterns. Each profile contains four units. One, two, and three units, respectively, received treatment. The treatment rates are therefore 0.25, 0.50, and 0.75. These profiles are a compact way to display this example; they are not a substitute for checking individual-level covariate balance.

Suppose a GAM, random forest, and gradient-boosting model are fit using the same candidate covariates and a common tuning protocol. To avoid assessing each model on the very observations used to fit it, suppose the displayed values are cross-fitted predictions: each unit’s probability was predicted by a model fit without that unit. The table reports the average prediction within each profile. The numerical outputs are hypothetical.

Covariate profileUnitsTreatedObserved treatment rateGAM mean predictionRandom forest mean predictionGradient boosting mean prediction
Low410.250.270.180.22
Middle420.500.480.500.55
High430.750.720.820.78

Worked Example: Reading a Predicted Probability

For the middle profile, the GAM’s mean estimated propensity score is 0.48, the random forest’s is 0.50, and the boosting model’s is 0.55. The random forest’s value means that its predicted treatment probability averages 0.50 among the four units in this profile. It does not mean that exactly half of these particular units must be treated, nor that each unit has an individual score of exactly 0.50.

The observed rate in the profile is \(2/4=0.50\). Thus, the absolute difference between the GAM’s mean prediction and the observed rate is

$$ |0.48-0.50|=0.02. $$

The corresponding differences for the random forest and boosting model are \(|0.50-0.50|=0.00\) and \(|0.55-0.50|=0.05\). These are profile-level comparisons, not measures of the errors for each individual probability.

Calibration: What the Grouped Comparison Shows

A model is calibrated in a group, in a practical empirical sense, when the mean predicted probability in that group is close to the observed treatment rate. In a population statement, calibration means that among units assigned a predicted probability \(q\), the treatment probability is \(q\). With a finite dataset, this relationship is assessed approximately, often by grouping predictions and comparing group means. Results depend on how groups are formed, and sparse groups can make the comparison noisy.

For this example, compare each model’s mean prediction with the observed rate in each of the three prespecified profiles. A weighted mean absolute calibration gap is

$$ \frac{\sum_{g=1}^{G} n_g\left|\bar{\hat e}_g-\hat p_g\right|}{\sum_{g=1}^{G}n_g}, $$

where \(n_g\) is the number of units in profile \(g\), \(\bar{\hat e}_g\) is the mean predicted probability there, and \(\hat p_g\) is the observed treatment rate there. This is a descriptive summary for these particular groups, not a universal measure of calibration.

Worked Example: Calculating the Calibration Summary

Each profile contains four units, so the three profiles receive equal weight. For the GAM, the absolute gaps are 0.02 in the low profile, 0.02 in the middle profile, and 0.03 in the high profile. Substituting these gaps gives

$$ \frac{4(0.02)+4(0.02)+4(0.03)}{12} =\frac{0.28}{12} =0.0233. $$

The calculation for the random forest uses gaps 0.07, 0.00, and 0.07:

$$ \frac{4(0.07)+4(0.00)+4(0.07)}{12} =\frac{0.56}{12} =0.0467. $$

For gradient boosting, the gaps are 0.03, 0.05, and 0.03, so the summary is

$$ \frac{4(0.03)+4(0.05)+4(0.03)}{12} =\frac{0.44}{12} =0.0367. $$

By this particular grouped summary, the GAM has the smallest average absolute calibration gap, followed by boosting and then the random forest. The gaps are differences in probabilities, so, for example, 0.0233 is about 2.33 percentage points. With only four units per profile, these figures should not be treated as precise evidence that the GAM is better calibrated in the population.

Comparing Predictions Without Declaring a Winner

A useful comparison asks both how well predictions align with observed treatment frequencies and how much the estimates differ across methods. In the table, the three methods order the profiles in the same way, from lower to higher estimated probability. But their levels differ. For the high profile, the random forest predicts 0.82 on average, compared with 0.72 for the GAM, a difference of

$$ |0.82-0.72|=0.10. $$

That is a 10-percentage-point difference in average predicted treatment probability for the profile. It may reflect different assumptions about the covariate-response relationship, tuning choices, or sampling variability. It does not, by itself, show which estimate is correct. Nor does the close match between a group’s predicted and observed treatment rates guarantee that the resulting propensity scores balance every relevant covariate.

Worked Example: Comparing the Overall Mean Predictions

Because the three profiles have equal size, each model’s overall mean prediction is the average of its three profile means. The GAM’s overall mean is

$$ \frac{0.27+0.48+0.72}{3}=0.49. $$

The random forest’s mean is \((0.18+0.50+0.82)/3=0.50\), and the boosting model’s mean is \((0.22+0.55+0.78)/3=0.5167\). The observed treatment rate for all 12 units is

$$ \frac{1+2+3}{12}=\frac{6}{12}=0.50. $$

The random forest’s overall mean equals the observed prevalence in this example. That fact alone does not establish better calibration: the model could match the overall rate while making substantial errors within subgroups. Here, the profile-level gaps provide additional information, but still do not establish individual-level calibration or adequate covariate balance.

A Short Justification for Cross-Fitted Calibration Checks

When predictions are evaluated on the same observations used to fit a flexible model, the model has already used those treatment labels to choose its predictions. Its apparent agreement with the observed treatment rates can therefore be overly optimistic. Cross-fitting separates prediction from the treatment label of the unit being predicted: partition the data into folds, fit the model on the other folds, and predict the held-out fold. Repeating this yields an out-of-fold prediction for each unit.

The logic is that the held-out unit’s treatment label did not directly determine its own fitted prediction. Consequently, the resulting grouped comparison is a more honest check of prediction performance than an in-sample comparison, although it can still be noisy and depends on the fold construction and tuning procedure. If model tuning itself uses treatment outcomes, that tuning must also be handled within the training data for each fold to avoid information leakage.

1
Define the common prediction task.
Use the same treatment indicator, observed covariates, and units for each model being compared.
2
Fit and tune without using held-out labels.
For cross-fitted evaluation, perform model fitting and any outcome-informed tuning using training folds only.
3
Compare probabilities and diagnostics.
Inspect their distributions and grouped calibration, then assess whether their use supports adequate covariate balance in the intended analysis.

Diagnostics, Alternatives, and Limitations

Calibration is one diagnostic among several. Check whether predictions are concentrated near zero or one, whether estimates are implausibly constant, and whether calibration changes across relevant covariate subgroups. Extreme estimated scores can indicate limited overlap or model behavior that warrants investigation; a well-calibrated overall average does not make such concerns disappear. The earlier material on calibration, cross-validation, out-of-fold prediction, and extreme fitted scores gives the relevant diagnostic foundations.

The main alternatives in this comparison make different compromises. A specified logistic model can be easier to interpret but may miss nonlinearities or interactions if its specification is too restrictive. A GAM can allow smooth effects while retaining an additive structure, but does not automatically capture all interactions. Random forests and boosting can represent more complex patterns, but their predictions depend on tuning and may be less transparent. These are tendencies, not guarantees: a simple model can predict well when its structure is appropriate, and a flexible model can perform poorly.

A fair decision should consider the purpose of the score, not only classification or calibration summaries. For propensity-score use, evaluate balance on the covariates relevant to the analysis after applying the intended adjustment, as well as overlap and the stability of the resulting estimates. Do not select a model solely because its in-sample predictions look calibrated or because it predicts treatment labels accurately. Treatment prediction accuracy is not the same as causal adjustment quality.

Common pitfall: “The random forest’s overall mean prediction equals the observed treatment rate, so it must be the best propensity model.” This conclusion does not follow. Overall agreement can hide subgroup or individual-level miscalibration, and calibration alone does not demonstrate covariate balance or causal identification. Compare out-of-fold predictions, inspect relevant subgroups and overlap, and evaluate balance for the analysis being planned.

The example also has important limits. Three covariate profiles and 12 units provide a transparent arithmetic exercise, not enough information to establish population performance. Grouped calibration summaries depend on the chosen groups, while model predictions can vary with the sample and tuning choices. Prediction disagreement is a prompt to examine assumptions and diagnostics, not a confidence interval for the true propensity score.

Check Your Understanding

Answer the questions, then compare your reasoning with the solutions.

  1. In the middle profile, what is the random forest’s mean prediction, and how does it compare with the observed treatment rate?
  2. Using the table, calculate the GAM’s absolute calibration gap in the high profile.
  3. Why does matching the overall observed treatment rate not establish that a model is calibrated within subgroups?
  4. Why are cross-fitted predictions useful when evaluating flexible propensity models?
  5. Name one structural difference between a GAM and a random forest, and explain why their estimates might differ.

Solutions. (1) The random forest predicts 0.50 on average, equal to the observed rate \(2/4=0.50\) in that profile. (2) The high-profile observed rate is \(3/4=0.75\); the GAM predicts 0.72, so the absolute gap is \(|0.72-0.75|=0.03\), or 3 percentage points. (3) Positive and negative errors across subgroups can cancel in the overall mean, so subgroup comparisons are needed. (4) Each unit is predicted by a fit that did not use that unit’s treatment label, reducing the optimism that can arise from evaluating predictions on training data. (5) A GAM commonly represents smooth additive covariate effects, whereas a random forest aggregates tree predictions and can represent interactions through tree splits; these different structures can yield different probabilities.

Clinical Biostats