60 Estimating IPW Weights
The Problem: Unknown Weights
Where We Are
In Lecture 14a, we saw that inverse probability weighting eliminates the modeling part of our error. When we know the treatment probabilities \(\pi(x)\)—or equivalently the covariate distributions \(m_{0x}\) and \(m_{1x}\)—we can compute the weights \[ \gamma(w,x) = \frac{m_{0x}}{m_{wx}} \] and use weighted least squares to get unbiased estimates of targets like \(\Delta_0\).
But what if we don’t know these probabilities?
When We Don’t Know the Treatment Distribution
In randomized experiments, we know \(\pi(x)\) because we chose it. In observational studies, we don’t. People choose their own treatments based on covariates, and we have to estimate the treatment distribution from data.
Everything is the same except that we don’t know \(\pi(x)\). This means that when we go to do weighted least squares, we don’t know the weights. We’ll use some estimate \(\hat\pi(x)\).
Let’s think about how much this matters.
- Forget the statistical part. That’s fine no matter what the weights are.
- Let’s look at the modeling part.
\[ \begin{aligned} \text{modeling part} &= \int \{\tilde\mu(w) - \mu(w)\}q(w)dw \\ &= \int \frac{q(w)}{\tilde p(w)} \{\tilde\mu(w) - \mu(w)\} p(w) dw \\ &+ \int \left\{ \frac{q(w)}{p(w)}-\frac{q(w)}{\tilde p(w)}\right\} \{\tilde\mu(w) - \mu(w)\} p(w) dw \\ &= \text{zero term} + \text{new term}. \end{aligned} \]
where \[ \begin{aligned} \text{new term} &= \int \frac{q(w)\{\tilde p(w) - p(w)\}}{p(w)\tilde p(w)} \{\tilde\mu(w) - \mu(w)\} p(w) dw \\ &= \int \frac{\{\tilde p(w) - p(w)\} \{\tilde\mu(w) - \mu(w)\}}{\tilde p(w)} q(w) dw. \end{aligned} \]
When Is This Small?
\[ \text{modeling error} = \int \frac{\{\tilde p(w) - p(w)\} \{\tilde\mu(w) - \mu(w)\}}{\tilde p(w)} q(w) dw \]
If we think of \(\tilde p\) as the limit of a fitted curve, then our estimate is good if
- Our model for the outcome is good, so \(\tilde \mu \approx \mu\).
- Our model for the treatment is good, so \(\tilde p \approx p\).
- Neither is good, but the errors are orthogonal to each other.
This is the double robustness property: we need only one of our two models to be right.
Approach 1: Regression to Predict Treatment
Estimating the Propensity Score
The most common approach is to estimate the treatment probability \(\pi(x) = P(W_i=1 \mid X_i=x)\) directly by regressing the treatment indicator on covariates.
In the discrete case with a saturated model, this is simple: fit lm(w ~ factor(x)) or equivalently compute the fraction treated at each covariate value. \[
\hat\pi(x) = \frac{N_{1x}}{N_{0x} + N_{1x}}
\]
The estimated weights are then \[ \hat\gamma(w,x) = \frac{\hat m_{0x}}{\hat m_{wx}} = \frac{N_{0x}}{N_{wx}}. \]
This is exactly what we did in the “Using Sample Proportions” version in Lecture 14a.
Limitations of the Regression Approach
When covariates are continuous or high-dimensional, we can’t use a saturated model. We have to fit a parametric model for \(\pi(x)\), typically logistic regression: \[ \log \frac{\pi(x)}{1-\pi(x)} = \phi(x)^T \alpha. \]
This introduces model dependence: if the logistic model is wrong, the estimated weights will be wrong. The modeling error from the previous section kicks in: the product \(\{\tilde p(w) - p(w)\}\{\tilde\mu(w) - \mu(w)\}\) won’t vanish just because we get the outcome model right. This is where double robustness helps.
Approach 2: Balancing
The Idea
Instead of modeling the treatment probability, we can directly find weights that balance the covariates between the treatment groups. The goal is to find weights \(\gamma_i\) for the treated group such that the weighted covariate distribution matches the control group’s distribution.
We want weights such that \[ \frac{\sum_{i:W_i=1} \gamma_i \phi(X_i)}{\sum_{i:W_i=1} \gamma_i} \approx \frac{1}{m_0} \sum_{j:W_j=0} \phi(X_j) \] for some set of covariate functions \(\phi\).
For example, with three covariate levels \(x \in \{20, 30, 40\}\), we’d want weights \(\gamma_i\) for the treated group such that the weighted fraction of treated observations at each \(x\) matches the control group’s distribution. A balance table comparing \(\frac{\sum_{i:W_i=1} \gamma_i 1(X_i=x)}{\sum_{i:W_i=1} \gamma_i}\) to \(\frac{N_{0x}}{N_0}\) shows whether the reweighting worked.
Why This Helps
The balancing approach has a different failure mode than regression.
- Regression can fail if the model for \(\pi(x)\) is wrong.
- Balancing can fail if the covariate functions \(\phi\) you choose to balance don’t capture the relevant differences.
But balancing has a practical advantage: you can check whether the covariates are balanced after weighting. You can look at the weighted means and see if they match. With regression, you have to trust your model.
Connection to Lecture 15
The balancing approach leads naturally into the application in Lecture 15, where we’ll see how these ideas are used in a real study. The key insight from that application is that when you have many covariates, balancing all of them simultaneously requires finding weights that solve a system of equations. This connects to optimization and duality—topics we’ll explore further in the enrichment day on duality.
Summary
Two approaches to estimating IPW weights when the treatment distribution is unknown:
- Regression approach: Model \(\pi(x)\) directly (e.g. logistic regression), then compute \(\hat\gamma = \hat m_{0x}/\hat m_{wx}\).
- Simple and familiar.
- Model dependent: if the propensity score model is wrong, bias remains.
- Balancing approach: Find weights that directly equalize covariate distributions between groups.
- Doesn’t require a model for the treatment distribution.
- Lets you verify that balance is achieved.
- Connects to optimization and duality.
Both approaches share the double robustness property: the modeling error is a product of errors in the outcome model and the weight model. If either is right, the modeling error vanishes.