Created
April 29, 2020 15:20
-
-
Save acoppock/d4793bca5a6c1f013c52245ba3f828bd to your computer and use it in GitHub Desktop.
Revisions
-
acoppock created this gist
Apr 29, 2020 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,21 @@ library(DeclareDesign) library(tidyverse) design <- declare_population(N = 50, type = sample(c("complier", "nevertaker"), N, replace = TRUE)) + declare_potential_outcomes(D ~ Z * (type == "complier")) + declare_potential_outcomes(Y ~ 5 * Z + rnorm(N)) + declare_assignment(prob = 0.5) + declare_estimand(CACE = mean(Y_Z_1 - Y_Z_0), subset = type == "complier") + declare_estimand(ATT = mean(Y_Z_1 - Y_Z_0), subset = D == 1) # Different in a single draw draw_estimands(design) # Same in expectation simulate_design(design, sims = 500) %>% group_by(estimand_label) %>% summarise(mean_estimand = mean(estimand))