A tiny experiment in fair comparisons

Propensity playground

160 fictional patients

Does a coaching program improve a 30-day recovery score? Sicker patients are more likely to receive coaching—and tend to recover less well.

Fair coin assignmentVery poor overlap
No benefit+16 recovery points
Try a scenario:
The raw difference mixes the coaching effect with differences in baseline severity.

Same people. Different contributions.

One dot = one patient
CoachingRoutine careEqual dot area = equal influence
Patients included
Severity imbalance · |SMD|
Estimated coaching effect
How does weighting change the result? Follow the arithmetic.Patient outcome → contribution → group average → estimated effect

Each patient's recorded outcome stays the same when you switch methods. Raw comparison counts everyone once. Matching averages only the retained patients. IPTW changes how much each patient contributes to their group's average. The difference between the two averages is the estimated coaching effect.

A two-score warm-up. Scores of 40 and 80 have an ordinary mean of (40 + 80) ÷ 2 = 60. Give them weights 2 and 6: (2 × 40 + 6 × 80) ÷ (2 + 6) = 70. The score of 80 now has 75% of the influence. The recorded scores are still 40 and 80.
Those weights illustrate averaging. All calculations below use the live cohort and its actual analysis weights.

1 · Follow one fixed outcome into the average

“Points contributed” is one piece of a group average, not a new outcome for that patient. All patient shares within a group add to 100%; their point contributions add to that group's mean.

2 · Add the products, then divide by total weight

Group average = Σ(weight × recorded outcome) ÷ Σ(weight)
Σ means “add across patients in this group.” Do this separately for coaching and routine care.
MethodCoaching averageRoutine-care average

Use total analysis weight as the denominator. For raw comparison and matching, this equals included headcount. ESS is a diagnostic, not the denominator. Displayed values are rounded to 3 decimals; calculations use full precision.

Audit the patient rows behind these sums

PatientScore yPropensity eWeight wProduct w × yGroup shareMean points

Totals above use the whole group, including rows on other pages. Unmatched patients remain visible with weight 0. Select a patient number to follow that person's arithmetic in step 1.

3 · Subtract routine care from coaching

Estimated effect = coaching average − routine-care average. Positive values favor coaching on this fictional recovery score.

4 · See why balancing severity moves the answer

In this invented model, each extra severity point lowers expected recovery by 0.48 points. A group that starts sicker therefore has a lower average even before considering coaching. Matching and weighting change the severity mix being averaged.

Estimated effect = true benefit + severity term + noise term
Severity term = −0.48 × (coaching severity average − routine-care severity average)
Noise term = coaching average noise − routine-care average noise
MethodTrue benefitSeverity termNoise termEstimated effect

This decomposition is possible because the simulator knows the true benefit and each person's random noise. Real observational studies do not know those quantities. Adjustment can reduce measured confounding; it does not force the result to equal the truth. Changing the “true benefit” slider creates different simulated outcomes; switching analysis methods keeps them fixed.

Are the groups comparable?

Baseline severity mix · share of each group (%)

Both colors use the same 0–100% scale. Under IPTW, bars show weighted shares.

Three estimates, one known truth

Coaching minus routine care · recovery score points

Method|SMD|IncludedESS*

*ESS = sum of the two groups' effective sample sizes; a weight-concentration diagnostic, not an exact precision estimate.

Try this first · Can helpful care look harmful?

Use the same patients throughout: start with the raw comparison, then match pairs, then apply IPTW. Watch what changes—and which people keep their original group.

How the two methods work · and what this toy example assumes

Propensity score ≠ recovery probability

The propensity score, e, is the probability of receiving coaching given baseline severity. It is estimated here by logistic regression using all 160 patients, before comparing outcomes.

Matching: 1:1 nearest-neighbor matching without replacement, in a fixed seeded patient order. The maximum permitted distance is the slider value × the full cohort's sample SD of the logit of the propensity score. Each retained patient counts once; no one switches group.

IPTW: coaching patients receive weight 1/e; routine-care patients receive 1/(1−e). Stabilization multiplies these by the observed coaching share and routine-care share, respectively. Each outcome mean is divided by its group's sum of weights.

Who is the answer about?

IPTW shown here targets the ATE: the average effect in the original eligible population. It retains everyone, but rare treatment choices can receive large weights when overlap is poor.

Matching starts with an ATT target: the effect among coaching recipients. If the caliper excludes some recipients, the result pertains to the retained, matchable recipients—not automatically to every treated patient. The fictional benefit is constant, so these target effects happen to be identical here.

Both methods rely on adequate overlap, a suitable propensity model, and measuring the relevant confounders. Neither fixes unmeasured confounding or guarantees balance in every sample. The example contains severity as its only confounder.

What is being simulated?

160 newly generated fictional records; severity from 0 to 100. Coaching probability follows a logistic model whose slope is controlled by selection strength. Recovery = 78 − 0.48 × severity + individual noise + the true benefit if coached. Changing the benefit leaves treatment assignment and matching unchanged.

No real patients, study data, clinical claims, or product names. This is a teaching simulation. The recovery score and all generating rules are invented.

Read the diagnostics

|SMD| is the absolute difference in severity means divided by the original unweighted pooled within-group SD, kept fixed across methods. Below 0.10 is a common balance heuristic, not proof that confounding has vanished.

Within each group, ESS = (sum of weights)² / sum of squared weights. Weighted totals are analytical influence, not extra patients. No confidence intervals are shown; real inference must account for weighting or matched pairs.

Method references: Austin & Stuart, 2015; Austin, 2011.