I'm trying to understand and ideally implement the Inverse Probability Weighting approach to estimate a causal effect. My ressources so far have been Pearl's Primer and the book "What If?". For binary treatment, it seems a common approach is a simple logistic regression. For non-binary treatment, I'm less sure. One could use a linear model or a GAM to model the conditional distribution in $$W^A=\frac{1}{f(A|Y)}.$$ However, this seems sensitive to the choice of model. It seems very attractive to me to use machine learning or neural networks for these weights. At this point, I don't really know how to use any Causal Inference packages or how they work. Modeling a conditional distribution is a bit more difficult than the usual modeling of the conditional expectation using machine learning, but I've tried to look into the existing approaches. It seems that one could use quantile regression, by simply modifying the loss function, and calculate a grid of quantiles. I've also heard of other approaches like VAEs, Normalizing Flows, or Bayesian Neural Networks (I don't really know anything about how the latter two work). How would you address this problem? What approach is feasible? What is done in current statistical software? I'd also appreciate advice on whether R/python are better for using statistical libraries. For now I've been trying to implement a bit of the theory in Python, but the field is quite big and I am a bit lost. Thank you very much for any answers.
1 Answer
IPW for continuous tretaments is definitely a bit more involved. The weights needs to be stabilized by the unconditional density, so typically weights are written as $$ w_i = \frac{f_A(a_i)}{f_{A|X}(a_i|x_i)} $$
where $f_A(a_i)$ is the unconditional density of $A$ evaluated at $A=a_i$ and $f_{A|X}(a_i|x_i)$ is the conditional density of $A$ given $X$ evaluated at $a_i$ for a covariate profile of $x_i$.
You are correct that this is much more involved than just estimating a conditional probability because you need to model the entire conditional distribution. This typically isn't too hard to do in practice, especially if you use maximum likelihood (since you are already proposing a conditional density and estimating its parameters), but the weights can be highly sensitive to the choice of densities used. Naimi et al. (2014) describe some methods of modeling the densities that perform differently in different circumstances.
The most common strategy is to assume $A|X \sim N(X \beta, \sigma^2_\varepsilon)$ where $\beta$ is a vector of coefficients on a linear regression of $A$ on $X$ (including an intercept) and $\sigma^2_\varepsilon$ is the residual variance, so that $f_A(a_i) = \phi(\frac{a_i - \bar{a}}{\sigma_A})$ and $f_{A|X}(a_i|x_i) = \phi(\frac{a_i - x_i \beta}{\sigma_\varepsilon})$ where $\phi(.)$ is the standard normal density and $\bar a$ and $\sigma_A$ are the unconditional mean and standard deviation of $A$, respectively.
However, other methods of estimating the conditional mean are available even when using the normal density; for example, one can do as you proposed and use a machine learning model to model the conditional mean and then use the normal density to compute the weights. While this still relies on correct specification of the density, it relaxes the parametric assumption on the conditional mean.
It is possible to use other methods of density estimation, like kernel density estimation, or parameterizing a model to model both the conditional mean and other conditional moments. There are also some weighting approaches the skip modeling the conditional density and estimate the weights directly, like entropy balancing and distance covariance optimal weights (DCOWs).
I recommend the R package WeightIt
, of which I am the author, for implementing and comparing these and other methods of estimating weights for continuous treatments. WeightIt
provides a lot of flexibility in how the weights are estimated and can be good to benchmark against a manual implementation to understand how the methods work. The WeightIt
source code for these methods is usually not too hard to read, too, so you can use it for inspiration.
-
$\begingroup$ Thank you very much for this detailed answer. (I know comments are not supposed to only say thanks, but I think it's important). I'll look at implementations in WeightIt. If you assume a nonlinear SEM, isn't it a bit limiting to assume that $f(A|Z)$ is a normal density, even if we use deep learning to estimate the mean, because it can be very misspecified in the tails? $\endgroup$ Commented Oct 3 at 13:07
-
$\begingroup$ Estimating multiple moments seems interesting. Splines and KDEs are problematic in high dimensions, right? It seems to me like this calls for bayesian neural networks to model the conditional density. Do you by chance know anything about that? I know this is kind of off topic, but I'm wondering what the problem is with doing quantile regression with neural networks, and simply computing a grid of quantiles to obtain the distribution of A that way. I'm probably being dumb and there is probably an issue with that? $\endgroup$ Commented Oct 3 at 13:16
-
1$\begingroup$ It is very limiting to propose any parametric form for the density. I was describing the norms in the field, not theoretically best practice. Your ideas sound cool and you should try coding them up and comparing them to existing methods! I don't know anything about neural networks but my understanding is they require huge amounts of data and lots of tuning to work well. $\endgroup$– NoahCommented Oct 3 at 15:22