Add a step to an existing design

add_step(..., before = NULL, after = NULL)

Arguments

...

bare (unquoted) names of step(s) to add to a design

before

bare (unquoted) name of the step before which to add steps

after

bare (unquoted) name of the step after which to add steps

Details

see modify_design for details.

Examples

my_population <- declare_population(N = 100, noise = rnorm(N)) my_potential_outcomes <- declare_potential_outcomes(Y_Z_0 = noise, Y_Z_1 = noise + rnorm(N, mean = 2, sd = 2)) my_assignment <- declare_assignment(m = 50) my_assignment_2 <- declare_assignment(m = 25) design <- declare_design(my_population, my_potential_outcomes, my_assignment) design
#> #> Design Summary #> #> Step 1 (population): my_population --------------------------------------------- #> #> N = 100 #> #> Added variable: ID #> N_missing N_unique #> 0 100 #> #> Added variable: noise #> min median mean max sd N_missing N_unique #> -2.61 0.09 0.07 2.76 1.05 0 100 #> #> Step 2 (potential outcomes): my_potential_outcomes ----------------------------- #> #> Added variable: Y_Z_0 #> min median mean max sd N_missing N_unique #> -2.61 0.09 0.07 2.76 1.05 0 100 #> #> Added variable: Y_Z_1 #> min median mean max sd N_missing N_unique #> -2.76 2.30 2.30 7.40 2.26 0 100 #> #> Step 3 (assignment): my_assignment --------------------------------------------- #> #> Random assignment procedure: Complete random assignment #> Number of units: 100 #> Number of treatment arms: 2 #> The possible treatment categories are 0 and 1. #> The probabilities of assignment are constant across units. #> #> Added variable: Z #> 0 1 #> Frequency 50 50 #> Proportion 0.50 0.50 #> #> Added variable: Z_cond_prob #> 0.5 #> Frequency 100 #> Proportion 1.00 #>
modify_design(design, replace_step(my_assignment_2, replace = my_assignment))
#> #> Design Summary #> #> Step 1 (population): my_population --------------------------------------------- #> #> N = 100 #> #> Added variable: ID #> N_missing N_unique #> 0 100 #> #> Added variable: noise #> min median mean max sd N_missing N_unique #> -2.45 -0.17 -0.16 2.48 0.99 0 100 #> #> Step 2 (potential outcomes): my_potential_outcomes ----------------------------- #> #> Added variable: Y_Z_0 #> min median mean max sd N_missing N_unique #> -2.45 -0.17 -0.16 2.48 0.99 0 100 #> #> Added variable: Y_Z_1 #> min median mean max sd N_missing N_unique #> -4.20 2.14 1.95 6.39 2.23 0 100 #> #> Step 3 (assignment): my_assignment_2 ------------------------------------------- #> #> Random assignment procedure: Complete random assignment #> Number of units: 100 #> Number of treatment arms: 2 #> The possible treatment categories are 0 and 1. #> The probabilities of assignment are constant across units. #> #> Added variable: Z #> 0 1 #> Frequency 75 25 #> Proportion 0.75 0.25 #> #> Added variable: Z_cond_prob #> 0.25 0.75 #> Frequency 25 75 #> Proportion 0.25 0.75 #>
modify_design(design, add_step(dplyr::mutate(income = noise^2), after = my_assignment))
#> #> Design Summary #> #> Step 1 (population): my_population --------------------------------------------- #> #> N = 100 #> #> Added variable: ID #> N_missing N_unique #> 0 100 #> #> Added variable: noise #> min median mean max sd N_missing N_unique #> -1.95 -0.02 -0.09 3.11 0.99 0 100 #> #> Step 2 (potential outcomes): my_potential_outcomes ----------------------------- #> #> Added variable: Y_Z_0 #> min median mean max sd N_missing N_unique #> -1.95 -0.02 -0.09 3.11 0.99 0 100 #> #> Added variable: Y_Z_1 #> min median mean max sd N_missing N_unique #> -2.90 2.01 2.08 6.66 1.89 0 100 #> #> Step 3 (assignment): my_assignment --------------------------------------------- #> #> Random assignment procedure: Complete random assignment #> Number of units: 100 #> Number of treatment arms: 2 #> The possible treatment categories are 0 and 1. #> The probabilities of assignment are constant across units. #> #> Added variable: Z #> 0 1 #> Frequency 50 50 #> Proportion 0.50 0.50 #> #> Added variable: Z_cond_prob #> 0.5 #> Frequency 100 #> Proportion 1.00 #> #> Step 4 (custom data modification): dplyr::mutate(income = noise^2) ------------- #> #> Added variable: income #> min median mean max sd N_missing N_unique #> 0.00 0.48 0.99 9.67 1.39 0 100 #>
modify_design(design, add_step(dplyr::mutate(income = noise^2), before = my_assignment))
#> #> Design Summary #> #> Step 1 (population): my_population --------------------------------------------- #> #> N = 100 #> #> Added variable: ID #> N_missing N_unique #> 0 100 #> #> Added variable: noise #> min median mean max sd N_missing N_unique #> -2.27 -0.04 -0.04 2.32 0.97 0 100 #> #> Step 2 (potential outcomes): my_potential_outcomes ----------------------------- #> #> Added variable: Y_Z_0 #> min median mean max sd N_missing N_unique #> -2.27 -0.04 -0.04 2.32 0.97 0 100 #> #> Added variable: Y_Z_1 #> min median mean max sd N_missing N_unique #> -3.05 1.77 1.86 6.81 2.25 0 100 #> #> Step 3 (custom data modification): dplyr::mutate(income = noise^2) ------------- #> #> Added variable: income #> min median mean max sd N_missing N_unique #> 0.00 0.48 0.93 5.37 1.15 0 100 #> #> Step 4 (assignment): my_assignment --------------------------------------------- #> #> Random assignment procedure: Complete random assignment #> Number of units: 100 #> Number of treatment arms: 2 #> The possible treatment categories are 0 and 1. #> The probabilities of assignment are constant across units. #> #> Added variable: Z #> 0 1 #> Frequency 50 50 #> Proportion 0.50 0.50 #> #> Added variable: Z_cond_prob #> 0.5 #> Frequency 100 #> Proportion 1.00 #>
modify_design(design, remove_step(my_assignment))
#> #> Design Summary #> #> Step 1 (population): my_population --------------------------------------------- #> #> N = 100 #> #> Added variable: ID #> N_missing N_unique #> 0 100 #> #> Added variable: noise #> min median mean max sd N_missing N_unique #> -2.25 0.11 0.06 3.10 1.02 0 100 #> #> Step 2 (potential outcomes): my_potential_outcomes ----------------------------- #> #> Added variable: Y_Z_0 #> min median mean max sd N_missing N_unique #> -2.25 0.11 0.06 3.10 1.02 0 100 #> #> Added variable: Y_Z_1 #> min median mean max sd N_missing N_unique #> -4.42 2.01 2.13 8.58 2.24 0 100 #>