Skip to contents


DirectEffects is an R package to estimate controlled direct effects (CDEs), which are the effect of a treatment fixing a set of downstream mediators to particular values. As of now, the package supports sequential g-estimation and a two-stage matching approach called telescope matching. For more information on how CDEs can be useful for applied research and a brief introduction to sequential g-estimation, see Acharya, Blackwell, and Sen (2016). For more on the telescope matching procedure, see Blackwell and Strezhnev (2022).


You can install DirectEffects via CRAN for the current stable version or via GitHub for the development version.

# Installing from CRAN

# Installing development version from Github:
# install.packages("devtools")
devtools::install_github("mattblackwell/DirectEffects", build_vignettes = TRUE)


The main functions for estimating CDEs in DirectEffects are:

  • sequential_g(): estimate controlled direct effects using two-stage linear models.
  • telescope_match(): estimated controlled direct effects using a two-stage matching procedure with bias correction.

DirectEffects also provides diagnostics for these two approaches, including sensitivity analyses and balance checks.