  When making causal inferences, post-treatment confounders complicate analyses
of time-varying treatment effects. Conditioning on these variables naively to
estimate marginal effects may inappropriately block causal pathways and may
induce spurious associations between treatment and the outcome, leading to
bias. To avoid such bias, researchers often use marginal structural models
(MSMs) with inverse probability weighting (IPW). However, IPW requires models
for the conditional distributions of treatment and is highly sensitive to their
misspecification. Moreover, IPW is relatively inefficient, susceptible to
finite-sample bias, and difficult to use with continuous treatments. We
introduce an alternative method of constructing weights for MSMs, which we call
"residual balancing." In contrast to IPW, it requires modeling the conditional
means of the post-treatment confounders rather than the conditional
distributions of treatment, and it is therefore easier to use with continuous
exposures. Numeric simulations suggest that residual balancing is both more
efficient and more robust to model misspecification than IPW and its variants.
We illustrate the method by estimating (a) the cumulative effect of negative
advertising on election outcomes and (b) the controlled direct effect of shared
democracy on public support for war. Open source software is available for
implementing the proposed method.
