Created
April 29, 2020 15:20
-
-
Save acoppock/d4793bca5a6c1f013c52245ba3f828bd to your computer and use it in GitHub Desktop.
ATTandCACE
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 characters
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)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment