Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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
Add Comment
Please, Sign In to add comment