directeffects

An R package for estimating controlled direct effects.

https://github.com/mattblackwell/directeffects

Science Score: 26.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (15.1%) to scientific vocabulary
Last synced: 9 months ago · JSON representation

Repository

An R package for estimating controlled direct effects.

Basic Info
Statistics
  • Stars: 18
  • Watchers: 6
  • Forks: 5
  • Open Issues: 5
  • Releases: 0
Created over 9 years ago · Last pushed over 1 year ago
Metadata Files
Readme

README.Rmd

---
output: github_document
---


# DirectEffects 

  [![R-CMD-check](https://github.com/mattblackwell/DirectEffects/workflows/R-CMD-check/badge.svg)](https://github.com/mattblackwell/DirectEffects/actions)


## Overview


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 general doubly robust estimation of CDEs under both selection-on-observables and difference-in-differences assumptions. 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)][de-paper]. For more on the telescope matching procedure, see  [Blackwell and Strezhnev (2022)][tm-paper]. For more on the difference-in-differences approach, see [Blackwell, Glynn, Hilbig, and Phillips (2024)][did-paper].


## Installation

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

```{r, eval = FALSE}
# Installing from CRAN
install.packages("DirectEffects")

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

## Usage


DirectEffects uses a modular approach to specifying the models and estimators used to estimate the average controlled direct effect (ACDE). You can specify a propensity score and outcome regression model for each treatment variable (that is, each causal variable of interest), along with a set of parametric and machine learning estimators for these nuisance functions. The package has a workflow for [models that assume the selection-on-observables](https://mattblackwell.github.io/DirectEffects/articles/DirectEffects.html) and for models that utilize a [difference-in-differences approach](https://mattblackwell.github.io/DirectEffects/articles/did_cde.html). 


```{r}
library(DirectEffects)

data(jobcorps)
my_aipw <- cde_aipw() |>
  set_treatment(treat, ~ female + age_cat) |>
  treat_model(engine = "logit") |>
  outreg_model(engine = "lm") |>
  set_treatment(work2year2q, ~ emplq4 + pemplq4) |>
  treat_model(engine = "logit") |>
  outreg_model(engine = "lm") |>
  estimate(exhealth30 ~ treat + work2year2q, data = jobcorps)

broom::tidy(my_aipw)
```




## Specific estimator implementations

DirectEffects also implements a number of specific estimators outside the modular framework. These are often specific estimators proposed in the literature:

- [`sequential_g()`](https://mattblackwell.github.io/DirectEffects/articles/sequential_g.html): estimate controlled direct effects using two-stage linear models. 
- [`telescope_match()`](https://mattblackwell.github.io/DirectEffects/articles/telescope_matching.html): 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. 

[de-paper]: http://www.mattblackwell.org/files/papers/direct-effects.pdf
[tm-paper]: https://www.mattblackwell.org/files/papers/telescope_matching.pdf
[did-paper]: https://www.mattblackwell.org/files/papers/did_cde.pdf

Owner

  • Name: Matthew Blackwell
  • Login: mattblackwell
  • Kind: user
  • Location: Cambridge, MA
  • Company: Harvard University

Associate Professor of Government, Harvard University

GitHub Events

Total
  • Issues event: 1
  • Push event: 4
Last Year
  • Issues event: 1
  • Push event: 4

Packages

  • Total packages: 1
  • Total downloads:
    • cran 268 last-month
  • Total docker downloads: 21,613
  • Total dependent packages: 0
  • Total dependent repositories: 0
  • Total versions: 4
  • Total maintainers: 1
cran.r-project.org: DirectEffects

Estimating Controlled Direct Effects for Explaining Causal Findings

  • Versions: 4
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 268 Last month
  • Docker Downloads: 21,613
Rankings
Dependent packages count: 29.8%
Dependent repos count: 35.5%
Average: 36.0%
Downloads: 42.7%
Maintainers (1)
Last synced: 10 months ago

Dependencies

DESCRIPTION cran
  • R >= 3.5.0 depends
  • Formula * imports
  • Matching * imports
  • broom * imports
  • generics * imports
  • glue * imports
  • rlang * imports
  • stats * imports
  • dplyr * suggests
  • ggplot2 * suggests
  • glmnet * suggests
  • hdm * suggests
  • knitr * suggests
  • nnet * suggests
  • ranger * suggests
  • reshape2 * suggests
  • rmarkdown * suggests
  • scales * suggests
  • testthat * suggests
.github/workflows/R-CMD-check.yaml actions
  • actions/checkout v4 composite
  • r-lib/actions/check-r-package v2 composite
  • r-lib/actions/setup-pandoc v2 composite
  • r-lib/actions/setup-r v2 composite
  • r-lib/actions/setup-r-dependencies v2 composite
.github/workflows/pkgdown.yaml actions
  • JamesIves/github-pages-deploy-action v4.5.0 composite
  • actions/checkout v4 composite
  • r-lib/actions/setup-pandoc v2 composite
  • r-lib/actions/setup-r v2 composite
  • r-lib/actions/setup-r-dependencies v2 composite