rbw: An R Package for Constructing Residual Balancing Weights

We describe the R package rbw, which implements the method of residual balancing weights (RBW) for estimating marginal structural models. In contrast to other methods such as inverse probability weighting (IPW) and covariate balancing propensity scores (CBPS), RBW involves modeling the conditional means of post-treatment confounders instead of the conditional distributions of the treatment to construct the weights. RBW is thus easier to use with continuous treatments, and the method is less susceptible to model misspecification issues that often arise when modeling the conditional distributions of treatments. RBW is also advantageous from a computational perspective. As its weighting procedure involves a convex optimization problem, RBW typically locates a solution considerably faster than other methods whose optimization relies on nonconvex loss functions — such as the recently proposed nonparametric version of CBPS. We explain the rationale behind RBW, describe the functions in rbw, and then use real-world data to illustrate their applications in three scenarios: effect estimation for point treatments, causal mediation analysis, and effect estimation for time-varying treatments with time-varying confounders.

Derick S. Baum (Harvard University) , Xiang Zhou (Harvard University)

Supplementary materials

Supplementary materials are available in addition to this article. It can be downloaded at RJ-2022-049.zip



Text and figures are licensed under Creative Commons Attribution CC BY 4.0. The figures that have been reused from other sources don't fall under this license and can be recognized by a note in their caption: "Figure from ...".


For attribution, please cite this work as

Baum & Zhou, "The R Journal: rbw: An R Package for Constructing Residual Balancing Weights", The R Journal, 2022

BibTeX citation

  author = {Baum, Derick S. and Zhou, Xiang},
  title = {The R Journal: rbw: An R Package for Constructing Residual Balancing Weights},
  journal = {The R Journal},
  year = {2022},
  note = {https://doi.org/10.32614/RJ-2022-049},
  doi = {10.32614/RJ-2022-049},
  volume = {14},
  issue = {3},
  issn = {2073-4859},
  pages = {174-192}