DeclareDesign

DeclareDesign declares, diagnoses, and redesigns research designs. A design is written as four parts, a model of the world, an inquiry about it, a data strategy, and an answer strategy, joined with +; diagnose_design() then simulates it and reports bias, power, coverage, and whatever else you ask for, before any data are collected.

library(DeclareDesign)

design <-
  declare_model(N = 100, U = rnorm(N), potential_outcomes(Y ~ 0.2 * Z + U)) +
  declare_inquiry(ATE = mean(Y_Z_1 - Y_Z_0)) +
  declare_assignment(Z = complete_ra(N)) +
  declare_measurement(Y = reveal_outcomes(Y ~ Z)) +
  declare_estimator(Y ~ Z, .method = difference_in_means, inquiry = "ATE")

diagnose_design(design)
#> Research design diagnosis
#>   500 simulations
#>   bootstrap standard errors in parentheses (100 replicates)
#>
#>  Design Inquiry Estimator Outcome Term N Sims Mean Estimand Mean Estimate
#>  design     ATE estimator       Y    Z    500          0.20          0.20
#>                                                      (0.00)        (0.01)
#>    Bias SD Estimate   RMSE  Power Coverage
#>    0.00        0.20   0.20   0.17     0.96
#>  (0.01)      (0.01) (0.01) (0.02)   (0.01)

library(DeclareDesign) also attaches the three companion packages that supply the pieces: fabricatr makes data, randomizr randomizes, and estimatr estimates. The book Research Design in the Social Sciences (Blair, Coppock, and Humphreys) works through all of it at https://book.declaredesign.org.

Installing

Install from CRAN, which brings fabricatr, randomizr, and estimatr 2.0 with it:

install.packages("DeclareDesign")

The development version is on GitHub:

remotes::install_github("DeclareDesign/DeclareDesign")

What changed in 2.0

2.0 is a ground-up rewrite on tidyverse foundations. The declaration syntax is unchanged, and the book’s designs run as written. What changed:

The changelog has the full list, and vignette("declaredesign2.0") the reasoning, the speed measurements, and a grep table for porting a script. vignette("getting-started") is the short introduction.