Modern Balancing

Python · from scratch  ·  R · WeightIt, CBPS, Matching, tmle  ·  LaLonde NSW/CPS

Targeting Balance Directly

The matching page followed the classic two-step dance: estimate a propensity score, match or weight on it, then check balance — and if balance is poor, respecify and try again. It works, but balance is an afterthought of a model fitted for a different objective, namely predicting treatment. A more modern generation targets balance directly, and pairs it with estimators that are doubly robust and statistically efficient.

Entropy balancing (Hainmueller 2012) solves for control weights that make the reweighted covariate moments exactly equal the treated group’s while staying as close to uniform as possible — balance by construction, no iteration. CBPS (Imai & Ratkovic 2014) estimates the propensity score so that it simultaneously fits treatment and balances covariates. Genetic matching (Diamond & Sekhon 2013) searches for the distance-metric weights that optimize balance. TMLE — targeted maximum likelihood estimation (van der Laan & Rubin 2006) — adds a targeting step to a plug-in estimator, achieving double robustness and the semiparametric efficiency bound.

Entropy Balancing, and What Exact Balance Costs

Entropy balancing skips the propensity model entirely. It finds weights wiw_i on the control units satisfying the balance constraints iwiXi=Xˉtreated\sum_i w_i X_i = \bar X_{\text{treated}} while maximizing entropy iwilogwi-\sum_i w_i \log w_i. The solution has the clean exponential form wiexp(λXi)w_i \propto \exp(-\lambda^\top X_i), with the multipliers found by a small convex dual. The payoff is real: balance is exact rather than approximate, and there is no fit-check-refit loop. Maximum imbalance collapses from 1.76 standardized units to 5 × 10−6.

maxw  iwilogwis.t.iwiXi=Xˉtreated,    iwi=1\max_w \; -\sum_i w_i \log w_i \quad \text{s.t.} \quad \sum_i w_i X_i = \bar X_{\text{treated}}, \;\; \sum_i w_i = 1

The exactness has a price the balance table does not show. Maximum entropy keeps the weights as uniform as the constraints allow — and where the control pool genuinely does not resemble the treated group, that is not very uniform at all. The effective control sample falls to 98 of 429, a 77% loss.

quantityvaluereading
max |SMD|, before → after1.762 → 5 × 10−6exact, by construction
effective control sample98 of 429a 77% loss
relative weight, median0.183the typical control counts for a fifth
relative weight, max9.42one control counts for nine
controls under a tenth of uniform weight120 of 429effectively discarded
weight held by the heaviest 2538%the estimate rests on a few dozen units

The typical control ends up carrying under a fifth of uniform weight while a handful carry more than nine times it, and the heaviest 25 of 429 hold 38% of the total. Exact balance is not free; it is paid for in variance. That trade is invisible if you report the balance table alone — and on a dataset with poor overlap, which is precisely when exact balancing looks most attractive, it is exactly when the bill comes due.

TMLE and the Targeting Step

TMLE combines an outcome model and a propensity model like AIPW, then adds a targeting step that updates the outcome model in the direction that removes bias for the causal parameter rather than for prediction. Fit Q^(A,X)\hat Q(A,X) and g^(X)\hat g(X), form the clever covariate H=(A(1A)g^1g^)/P^(A=1)H = \big(A - (1-A)\tfrac{\hat g}{1-\hat g}\big)/\hat P(A{=}1), regress the residual YQ^Y - \hat Q on HH with no intercept to get ε^\hat\varepsilon, and update Q^=Q^+ε^H\hat Q^\star = \hat Q + \hat\varepsilon H. It is doubly robust and attains the efficiency bound.

stageATT
initial plug-in g-computation: predict both potential outcomes from the outcome model and average the differenceUSD 1,548
targeting fluctuation ε−36.3
TMLE, after targetingUSD 1,199
experimental benchmarkUSD 1,794

Those are asymptotic guarantees, and this is one finite sample. Worth noting which way targeting moved things: the plug-in sat at USD 1,548 and TMLE moved it to USD 1,199USD 350 further from the USD 1,794 benchmark rather than closer. That is not evidence against TMLE. An estimator with better asymptotic properties can land worse on any single dataset, and the benchmark is only visible here because someone ran the experiment. It is a reminder that efficiency is a claim about repeated sampling, not about this answer.

Every Method Against the Benchmark

estimatorATTvs benchmark
naive (CPS controls)−USD 635wrong sign
NN-propensity matchingUSD 1,792essentially exact
IPWUSD 1,316−27%
entropy balancingUSD 1,273−29%
AIPWUSD 1,225−32%
TMLEUSD 1,199−33%

Experimental benchmark USD 1,794. Mahalanobis matching, at USD 719, is on the matching page. AIPW reads USD 1,225 here against USD 1,226 there because this notebook reuses the clipped propensity score from the TMLE section.

Lined up against the estimators from the matching page, the modern methods cluster in the same band — and that band sits roughly 30% below the experimental truth, which the far simpler nearest-neighbour propensity match had hit almost exactly. Sophistication bought better balance and better asymptotics here, not a closer answer.

That is not an argument against the modern toolkit, and the ranking on this one dataset should not be read as a ranking of methods — LaLonde is famously hard, and a single comparison against a single benchmark is one draw. What it does show is that optimizing the diagnostic is not the same as improving the estimate. Taken with the previous page, where the better-balanced matching scheme also produced the worse number, a pattern emerges: balance is a necessary condition that behaves poorly as an objective.

And the caveat from the sensitivity page governs all of it. Every estimate here assumes unconfoundedness, and the LaLonde matched estimate proved fragile at Γ=1.21\Gamma^\star = 1.21. Better balancing tightens what can be seen; it cannot rule out what cannot be seen. No amount of optimization at the weighting stage addresses an omitted confounder.

Where this sits

Entropy balancing is the calibration-weighting cousin of survey weighting and of IPW; TMLE is the efficient sibling of the AIPW estimators, and both point forward to Double/Debiased ML, where the nuisance models become machine learners and cross-fitting replaces the plug-in. All of it presumes the back-door condition that the DAG material makes graphical, and all of it inherits the fragility the sensitivity analysis quantifies.

Notebooks

Downloads

References