Tutorials › Propensity Score Matching and Instrumental Variables › Simulating HDPS Under Sparse Confounding

Time-Varying and High-Dimensional Confounding · Tutorial 642 of 699

Simulating HDPS Under Sparse Confounding

Build a reproducible simulation that reveals when HDPS selection improves confounding control and when sparsity, rare features, or limited overlap undermine it.

Advanced 13 min read

What You'll Learn

  • Specify a sparse-confounding data-generating process with a known average treatment effect.
  • Vary confounder prevalence and treatment and outcome associations separately.
  • Define HDPS feature-ranking rules precisely enough to reproduce them.
  • Compare bias, variance, RMSE, and covariate balance across strategies.
  • Separate Monte Carlo uncertainty from the sampling variability being studied.
  • Diagnose overlap problems, rare-feature instability, and misleading balance summaries.

Why Simulate HDPS Under Sparse Confounding?

High-dimensional propensity score (HDPS) methods are intended for settings with many measured candidate features but comparatively few important confounders. Their performance is not determined by the number of features alone. A rare confounder may be strongly associated with treatment but poorly estimated; a common feature may be weakly associated with treatment yet strongly prognostic for the outcome. Increasing the number of irrelevant features can also make selection and propensity estimation unstable. A simulation lets us vary these conditions separately while keeping the true treatment effect known.

The goal is not to construct a simulation that proves one strategy always wins. It is to specify a data-generating process (DGP), estimand, analysis strategies, and performance measures in advance, then see how results change across a planned grid of scenarios. Results are conditional on those choices: a simulation can reveal vulnerabilities in the designed settings, but it does not establish performance in every observational data set.

A Sparse-Confounding Data-Generating Process

Definition: Let \(X=(X_1,\ldots,X_p)\) be measured baseline features, \(A\in\{0,1\}\) treatment, and \(Y\) the outcome. A sparse-confounding DGP has many candidate features but only a small subset that jointly affect treatment and outcome. For a binary-treatment simulation, define potential outcomes \(Y(1)\) and \(Y(0)\), and the average treatment effect (ATE) as \(E[Y(1)-Y(0)]\).

One transparent starting point is to generate independent binary features \(X_j\sim\operatorname{Bernoulli}(q_j)\), then generate treatment according to

$$ P(A=1\mid X)=e(X)=\operatorname{expit}\left(\alpha_0+\sum_{j=1}^{p}\beta_jX_j\right), \qquad \operatorname{expit}(z)=\frac{1}{1+\exp(-z)}. $$

Choose only a few \(j\)'s to have both \(\beta_j\ne 0\) and a nonzero outcome coefficient \(\gamma_j\). Those are the true confounders in this particular DGP. Features with \(\beta_j=0\) but \(\gamma_j\ne 0\) are prognostic but do not affect treatment; features with \(\beta_j\ne 0\) but \(\gamma_j=0\) affect treatment but not the outcome conditional on the other features. The remaining features are null in both models.

$$ Y(a)=\tau a+\sum_{j=1}^{p}\gamma_jX_j+\varepsilon,\qquad a\in\{0,1\}. $$

For the main simulation, draw \(\varepsilon\sim N(0,\sigma^2)\) independently of \(X\) and of the random variable used to generate \(A\). Then the potential outcomes are independent of \(A\) conditional on \(X\), so full conditional exchangeability holds in this DGP. The true ATE is \(\tau\), since \(Y(1)-Y(0)=\tau\) for every unit. This explicit independence condition matters: merely imposing \(E[\varepsilon\mid A,X]=0\) gives a conditional-mean statement, not necessarily independence of the potential outcomes and treatment given \(X\). In this additive outcome model, the mean condition can support mean-based identification, but it should not be described as full exchangeability.

For every finite linear predictor, the logistic treatment probability is between zero and one. That mathematical positivity does not guarantee useful empirical overlap: some units can still have probabilities near zero or one, yielding extreme weights. Choose \(\alpha_0\) to target a prespecified marginal treatment proportion, such as one half, and record the resulting propensity distribution in each scenario. Recalibrate the intercept when changing other DGP parameters if holding the treatment proportion fixed is part of the design.

Specify the HDPS Strategies Before Running the Simulation

“HDPS” is not one uniquely defined ranking rule. To make a simulation reproducible, state exactly how features are screened and ranked. For example, require a minimum count of exposed and unexposed individuals with each binary feature present. Among eligible features, rank them by absolute treatment association, such as the absolute log odds ratio for \(A\) comparing \(X_j=1\) with \(X_j=0\). Separately rank them by the absolute standardized difference in outcome means between \(X_j=1\) and \(X_j=0\), measured among untreated individuals. Selecting the outcome association among controls avoids using the treatment effect itself as the feature’s outcome association in this example, though it remains an outcome-informed selection procedure.

Define the joint HDPS rule as retaining the \(k\) eligible features with the smallest sum of their two ranks, where rank 1 is strongest. Also define the treatment-only rule as retaining the \(k\) features with the strongest treatment association. These are operational definitions for a simulation, not claims that all implementations use these exact rules. Compare them with an oracle strategy that includes only the true confounders and a random-\(k\) feature strategy as a reference. Fit the same prespecified treatment model and use the same effect estimator for every strategy. This isolates differences due to feature choice more clearly than changing selection, model form, and estimator simultaneously.

Vary the factors in a planned grid: prevalence \(q_j\) of the true confounders, magnitudes and signs of their \(\beta_j\)'s, magnitudes of their \(\gamma_j\)'s, and total dimension \(p\). Also consider prognostic-only and treatment-only features, and vary the number of null features. State whether coefficients are held fixed or recalibrated as prevalence changes: the same log odds ratio can imply different marginal treatment imbalance when a feature is rare. Avoid changing several factors without recording them, since an apparent “dimension effect” could otherwise be caused by altered overlap or confounding strength.

Estimating Effects and Measuring Performance

For a fitted propensity score \(\hat e_i\), one common ATE estimator is the normalized inverse-probability weighted difference:

$$ \hat\tau_{\mathrm{IPW}}= \frac{\sum_{i=1}^{n} A_iY_i/\hat e_i}{\sum_{i=1}^{n} A_i/\hat e_i} - \frac{\sum_{i=1}^{n} (1-A_i)Y_i/(1-\hat e_i)} {\sum_{i=1}^{n} (1-A_i)/(1-\hat e_i)}. $$

The weighting rationale follows from conditional exchangeability and a correctly specified propensity score. For example, \(E[AY/e(X)\mid X]=E[Y\mid A=1,X]\), because \(P(A=1\mid X)=e(X)\). Averaging over \(X\), exchangeability and consistency give \(E[AY/e(X)]=E[Y(1)]\). Similarly, \(E[(1-A)Y/\{1-e(X)\}]=E[Y(0)]\). The displayed normalized estimator is a sample analogue using weighted group means; it is not exactly unbiased in every finite sample. Its consistency also relies on adequate overlap and a suitable propensity estimation strategy. If selection omits important confounders or the fitted model is inadequate, weighting need not remove confounding bias.

Across \(B\) independent simulated data sets, record the estimate \(\hat\tau_b\) in each replicate. Useful summaries include empirical bias, variance, and root mean squared error (RMSE):

$$ \widehat{\operatorname{Bias}}=\frac{1}{B}\sum_{b=1}^{B}\hat\tau_b-\tau,\qquad \widehat{\operatorname{Var}}=\frac{1}{B-1}\sum_{b=1}^{B}(\hat\tau_b-\bar{\hat\tau})^2,\qquad \widehat{\operatorname{RMSE}}= \sqrt{\frac{1}{B}\sum_{b=1}^{B}(\hat\tau_b-\tau)^2}. $$

Report balance as well as effect performance. For each feature, a standardized mean difference (SMD) compares its treated and control means; after weighting, use the weighted means and a clearly stated scale, such as the unweighted pooled standard deviation in the original sample. Summarize balance among true confounders separately from balance across all measured features. A small average SMD can hide a severely imbalanced rare confounder, so report a maximum or upper percentile too. Balance is a diagnostic, not proof that unmeasured confounding is absent or that the causal assumptions hold.

Worked Example: Ranking Features in One Simulated Replicate

Suppose a hypothetical replicate contains 1,000 units and four eligible binary features. The prespecified ranking uses absolute treatment log odds ratios and absolute outcome standardized differences among controls. The observed values are:

FeaturePrevalenceAbsolute treatment log odds ratioAbsolute outcome difference (standardized)Treatment rankOutcome rankRank sum
\(X_1\)0.200.800.50123
\(X_2\)0.500.300.70213
\(X_3\)0.031.100.100\(^*\)0\(^*\)0\(^*\)
\(X_4\)0.400.100.20336

Assume the screening rule requires at least 20 observations with the feature present in each treatment group. Feature \(X_3\) is observed in about \(0.03(1000)=30\) units overall and fails the required group-specific count in this replicate, so the asterisk means it is excluded rather than assigned a meaningful rank. For the other features, the joint rank sums are \(1+2=3\), \(2+1=3\), and \(3+3=6\). If \(k=2\), the joint rule selects \(X_1\) and \(X_2\). The treatment-only rule selects \(X_1\) and \(X_2\) here as well, but for a different reason: their treatment ranks are the two strongest among eligible features. This example shows why a screening rule and the handling of rare features must be specified, not left implicit.

Worked Example: Calculating a Weighted Estimate in One Replicate

Consider a deliberately small hypothetical replicate with true \(\tau=2\). Suppose the fitted scores and observed outcomes for two treated and two untreated units are as follows. These numbers illustrate the arithmetic only; four units cannot provide a reliable performance assessment.

UnitTreatment \(A_i\)Outcome \(Y_i\)Fitted propensity \(\hat e_i\)
1180.80
2160.40
3040.60
4020.20

The treated weights are \(1/0.80=1.25\) and \(1/0.40=2.50\). Their weighted mean outcome is \((1.25(8)+2.50(6))/(1.25+2.50)=25/3.75=6.667\). The control weights are \(1/(1-0.60)=2.50\) and \(1/(1-0.20)=1.25\), giving weighted mean \((2.50(4)+1.25(2))/3.75=12.5/3.75=3.333\). Thus \(\hat\tau_{\mathrm{IPW}}=20/3-10/3=10/3\approx3.333\), which is 1.333 outcome units above the true effect in this replicate. A single replicate’s error is not the estimator’s bias; bias is assessed by averaging estimates across repeated data sets.

Worked Example: Comparing Monte Carlo Performance

Suppose a hypothetical simulation uses \(B=1{,}000\) replicates, true \(\tau=2\) outcome units, and the same estimator for each strategy. The table reports illustrative replicate means and standard deviations, together with maximum absolute weighted SMDs averaged across replicates.

StrategyMean estimateSD of estimatesBiasRMSEMean maximum absolute SMD
Oracle true confounders2.030.300.030.3010.04
Joint HDPS ranking2.200.420.200.4650.08
Treatment-only ranking2.650.550.650.8510.18
Random \(k\) features2.120.800.120.8090.25

For joint HDPS, using the reported rounded summaries and \(B=1{,}000\), the finite-sample identity gives \(\mathrm{RMSE}=\sqrt{0.20^2+\frac{999}{1000}(0.42^2)}=\sqrt{0.2162236}=0.465\), to three significant figures. For the oracle, \(\mathrm{RMSE}=\sqrt{0.03^2+\frac{999}{1000}(0.30^2)}=\sqrt{0.09081}=0.301\). The joint rule improves on treatment-only ranking in this designed scenario, with lower bias, lower variance, lower RMSE, and better reported balance. It remains less accurate than the oracle, which knows the true confounders. These hypothetical results illustrate how to interpret a comparison; they are not empirical findings. A different prevalence, effect-size pattern, or overlap condition could change the ranking of strategies.

Diagnostics, Limitations, and Common Mistakes

For each scenario, inspect treatment counts, feature counts in both treatment groups, fitted propensity distributions, maximum weights, and effective sample size, in addition to balance and effect summaries. Record the frequency of failed model fits or separation rather than silently dropping those replicates. If the treatment model is unstable, distinguish failure to estimate a propensity from poor causal performance among the replicates that succeeded. Report the number of successful replicates and assess whether excluding failures changes the conclusions. When comparing dimension, hold sample size fixed or deliberately vary it as another factor, and state which choice was made.

The number \(B\) controls Monte Carlo precision, not the sampling variability within a data set. For example, the Monte Carlo standard error of the estimated mean effect is approximately the replicate standard deviation divided by \(\sqrt{B}\). If that value is large relative to differences between strategies, increase \(B\) before interpreting a small ranking difference as meaningful. Report both Monte Carlo uncertainty and the replicate-to-replicate spread.

  • Wrong: “The simulation generated an additive outcome with \(E[\varepsilon\mid A,X]=0\), so full exchangeability must hold.” Correction: A conditional-mean restriction alone does not imply equality of the full conditional distributions of potential outcomes. To claim full exchangeability in the stated DGP, generate \(\varepsilon\) independently of \((A,X)\), or separately justify the full conditional-independence condition.
  • Wrong: “The maximum SMD is small, so the estimated treatment effect is unbiased.” Correction: Balance on measured features is a diagnostic, not a guarantee against unmeasured confounding, selection error, or model misspecification. Check true-confounder balance in the simulation and calculate effect bias directly against the known \(\tau\).
  • Wrong: “More selected features must reduce bias.” Correction: Additional features may help control confounding or improve precision, but they may also worsen overlap, increase weight variability, or destabilize estimation. Compare bias and variance separately as well as through RMSE.
  • Wrong: “A rare feature with a large treatment association should always be retained.” Correction: Its importance also depends on outcome association and the information available to estimate its effect. Report screening and fit failures, and vary prevalence rather than relying on one sparse-feature scenario.

The oracle is a useful benchmark, not a feasible observational strategy: it assumes the analyst knows which features truly confound. A treatment-only rule avoids outcome-informed ranking but can omit strongly prognostic features. Joint ranking can identify features relevant to both models, yet its performance depends on how associations are measured and on the selected-feature count. These comparisons assess specified algorithms under specified DGPs; they do not establish that any strategy is universally preferable.

1
Write the estimand and DGP.
State the target effect, feature distribution, treatment assignment, outcome model, error assumptions, and which features are true confounders.
2
Build a scenario grid.
Vary prevalence, treatment and outcome associations, and feature dimension while tracking changes in treatment prevalence and overlap.
3
Fix selection and estimation rules.
Define screening, ranking, \(k\), propensity model, effect estimator, and failure handling before generating results.
4
Repeat and summarize.
Use independent replicates to estimate bias, variance, RMSE, balance, fit failures, and Monte Carlo uncertainty.
5
Interpret conditionally.
Explain which scenario features account for differences and avoid generalizing beyond the simulated settings.

Check Your Understanding

Answer each question, then compare with the solutions below.

  1. In the additive outcome model, what condition supports full conditional exchangeability, and why is a zero conditional error mean alone insufficient?
  2. If the mean estimate over \(B\) replicates is 2.18 when the true effect is 2, what is the estimated bias?
  3. Why should balance on rare true confounders be examined separately from average balance across all features?
  4. What does increasing the number of simulation replicates improve, and what does it not improve?

Solutions. (1) Require the error to be independent of \((A,X)\), or otherwise require the conditional distribution of the potential outcomes not to depend on \(A\) given \(X\). A zero conditional mean constrains only the mean and can coexist with different conditional distributions. (2) The estimated bias is \(2.18-2=0.18\) outcome units. (3) An average across many features can hide substantial imbalance in one important rare confounder; report confounder-specific and maximum or upper-percentile balance. (4) More replicates reduce Monte Carlo error in summaries such as the estimated mean and bias. They do not reduce the sampling variability of the estimator within a replicate or fix a misspecified DGP.

Clinical Biostats