Animated formulas

Matching and weighting

Follow eight people through two ways to estimate the effect among the treated. Who contributes, and how much?

Before adjustment

1 / 6
TreatedControlsT1Y = 12T2Y = 26T3Y = 26T4Y = 26C1Y = 10C2Y = 10C3Y = 10C4Y = 20

Each dot is one person. T identifies a treated person, C a control. Y is the observed outcome. The crude mean difference is 10.

Mean outcome

Treated22.5
Controls12.5

Difference 10

Try the effective sample size lab

How the formulas meet1nT∑i:Ai=1Ym(i)=1nT∑j:Aj=0kjYj\frac1{n_T}\sum_{i:A_i=1}Y_{m(i)}=\frac1{n_T}\sum_{j:A_j=0}k_jY_j

Here kⱼ counts how often control j was matched. For odds weighting within severity strata, the empirical odds e/(1−e) equal the number treated divided by the number of controls in that stratum. Both schemes balance severity for the ATT in this example. Their individual weights differ. A causal interpretation also requires consistency, adequate overlap and exchangeability for the untreated potential outcome among comparable people.

Explore ATT and ATE weighting in depth
Animated formulas

How does a weight change a comparison?

Eight people have one measured baseline characteristic: low or high severity. Three of four treated people have high severity, compared with one of four controls. The crude difference in mean outcomes is 22.5 − 12.5 = 10. How much of that comparison depends on the mix of people?

Choose whose population to represent

The propensity score e is the probability of treatment given severity. Here we estimate it by counting: 1/4 in the low stratum and 3/4 in the high stratum. Circle area represents a person’s contribution. The number beside each circle is the weight.

TreatedControlT1 · Low · 1T2 · High · 1T3 · High · 1T4 · High · 1C1 · Low · 1C2 · Low · 1C3 · Low · 1C4 · High · 1

High severity among treated / controls · 75% / 25%

Weighted mean difference · 22.5 − 12.5 = 10

Read the formula

wi=Ai+(1−Ai)ei1−eiw_i=A_i+(1-A_i)\frac{e_i}{1-e_i}

A equals 1 for a treated person and 0 for a control. Treated people keep weight 1. A high-severity control receives odds 3: that one control supplies three control-side contributions. Both sides end up 75% high severity.

Δ^=∑Ai=1wiYi∑Ai=1wi−∑Ai=0wiYi∑Ai=0wi\hat\Delta=\frac{\sum_{A_i=1}w_iY_i}{\sum_{A_i=1}w_i}-\frac{\sum_{A_i=0}w_iY_i}{\sum_{A_i=0}w_i}

Divide by the sum of weights separately in each arm. Only the final slider setting uses the chosen target weights; intermediate positions illustrate the transition.

Why do the targets differ?

In these constructed data, outcomes are constant within each severity and treatment cell. The low-severity contrast is 12 − 10 = 2; the high-severity contrast is 26 − 20 = 6. Among treated people their average is ¼ × 2 + ¾ × 6 = 5. Across everyone it is ½ × 2 + ½ × 6 = 4. Exact matching here retains every treated person. Without suitable controls, dropping treated people can change the target. In real samples, matching and weighting can differ even when they target the same effect.

What makes the contrast causal?

A causal interpretation requires consistency, conditional exchangeability for the relevant potential outcomes, and adequate overlap for the target population. Inspect covariate balance and influential weights. Balancing measured severity alone cannot rule out unmeasured confounding.

Compare with matching · Read the full course

Austin & Stuart (2015), Moving towards best practice when using inverse probability of treatment weighting (IPTW)

Full course · Matching vs Weighting

Stuart (2010) · Austin & Stuart (2015)