Helper functions for using the book Research Design in the Social Sciences: Declaration, Diagnosis, Redesign by Blair, Coppock, and Humphreys 2023 (Princeton University Press).
Install the released version from CRAN:
install.packages("rdss")or the development version from GitHub:
remotes::install_github("DeclareDesign/rdss")estimator_AS_tidy(), used in the book’s section on experiments over
networks, also needs the ‘interference’ package, which is not on CRAN:
remotes::install_github("szonszein/interference")did_multiplegt_tidy(), used in the book’s section on
difference-in-differences, needs the ‘polars’ package, which is also not
on CRAN:
install.packages("polars", repos = "https://rpolars.r-universe.dev")Each helper fills one step of a declaration in the book, and its help
page links to the section that uses it. lag_by_group(), for instance,
builds the lagged treatment indicator in the difference-in-differences
design:
library(rdss)
library(dplyr)
panel <-
tibble(
unit = rep(c("a", "b"), each = 3),
period = rep(1:3, times = 2),
D = c(0, 1, 1, 0, 0, 1)
) |>
mutate(D_lag = lag_by_group(D, groups = unit, n = 1, order_by = period))
panel## # A tibble: 6 × 4
## unit period D D_lag
## <chr> <int> <dbl> <dbl>
## 1 a 1 0 NA
## 2 a 2 1 0
## 3 a 3 1 1
## 4 b 1 0 NA
## 5 b 2 0 0
## 6 b 3 1 0