Created
September 12, 2018 21:16
-
-
Save acoppock/e84016e6e3f32cf2ff5dfb7f82505a28 to your computer and use it in GitHub Desktop.
"Shy Trump" list experiment design declaration
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) | |
proportion_shy <- .06 | |
population <- declare_population( | |
N = 5000, | |
# true trump vote (unobservable) | |
truthful_trump_vote = draw_binary(.45, N), | |
# shy voter (unobservable) | |
shy = draw_binary(proportion_shy, N), | |
# Direct question response (1 if Trump supporter and not shy, 0 otherwise) | |
Y_direct = as.numeric(truthful_trump_vote == 1 & shy == 0), | |
# Nonsensitive list experiment items | |
raise_minimum_wage = draw_binary(.8, N), | |
repeal_obamacare = draw_binary(.6, N), | |
ban_assault_weapons = draw_binary(.5, N) | |
) | |
potential_outcomes <- declare_potential_outcomes( | |
Y_list_Z_0 = raise_minimum_wage + repeal_obamacare + ban_assault_weapons, | |
Y_list_Z_1 = Y_list_Z_0 + truthful_trump_vote | |
) | |
# Inquiry ----------------------------------------------------------------- | |
estimand <- declare_estimand( | |
proportion_truthful_trump_vote = mean(truthful_trump_vote)) | |
# Data Strategy ----------------------------------------------------------- | |
sampling <- declare_sampling(n = 500) | |
assignment <- declare_assignment(prob = .5) | |
# Answer Strategy --------------------------------------------------------- | |
estimator_direct <- declare_estimator( | |
Y_direct ~ 1, | |
model = lm_robust, | |
term = "(Intercept)", | |
estimand = estimand, | |
label = "direct" | |
) | |
estimator_list <- declare_estimator(Y_list ~ Z, | |
model = difference_in_means, | |
estimand = estimand, | |
label = "list") | |
# Design ------------------------------------------------------------------ | |
design <- | |
population + | |
potential_outcomes + | |
sampling + | |
estimand + | |
assignment + | |
declare_reveal(outcome_variables = Y_list) + | |
estimator_direct + | |
estimator_list | |
draw_data(design) | |
diagnosis <- diagnose_design(design, sims = 500, bootstrap_sims = FALSE) | |
diagnosis |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment