Modify a Design

modify_design(design, ...)

Arguments

design

a design object, usually created by declare_design, quick_design, or download_design.

...

a series of calls to add_step, remove_step, or replace_step

Value

A design object. See declare_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 #> -3.11 -0.23 -0.12 2.30 1.07 0 100 #> #> Step 2 (potential outcomes): my_potential_outcomes ----------------------------- #> #> Added variable: Y_Z_0 #> min median mean max sd N_missing N_unique #> -3.11 -0.23 -0.12 2.30 1.07 0 100 #> #> Added variable: Y_Z_1 #> min median mean max sd N_missing N_unique #> -5.34 1.80 1.81 7.13 2.06 0 100 #> #> Step 3 (assignment): my_assignment --------------------------------------------- #> #> Added variable: Z #> 0 1 NA #> Frequency 50 50 0 #> Proportion 0.50 0.50 0.00 #> #> Added variable: Z_cond_prob #> 0.5 NA #> Frequency 100 0 #> Proportion 1.00 0.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 #> -3.17 -0.11 -0.11 2.58 1.16 0 100 #> #> Step 2 (potential outcomes): my_potential_outcomes ----------------------------- #> #> Added variable: Y_Z_0 #> min median mean max sd N_missing N_unique #> -3.17 -0.11 -0.11 2.58 1.16 0 100 #> #> Added variable: Y_Z_1 #> min median mean max sd N_missing N_unique #> -1.85 1.64 2.01 8.96 2.12 0 100 #> #> Step 3 (assignment): my_assignment_2 ------------------------------------------- #> #> Added variable: Z #> 0 1 NA #> Frequency 75 25 0 #> Proportion 0.75 0.25 0.00 #> #> Added variable: Z_cond_prob #> 0.25 0.75 NA #> Frequency 25 75 0 #> Proportion 0.25 0.75 0.00 #>
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 #> -2.22 0.01 0.06 2.76 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.22 0.01 0.06 2.76 0.99 0 100 #> #> Added variable: Y_Z_1 #> min median mean max sd N_missing N_unique #> -3.74 1.96 1.96 6.52 2.24 0 100 #> #> Step 3 (assignment): my_assignment --------------------------------------------- #> #> Added variable: Z #> 0 1 NA #> Frequency 50 50 0 #> Proportion 0.50 0.50 0.00 #> #> Added variable: Z_cond_prob #> 0.5 NA #> Frequency 100 0 #> Proportion 1.00 0.00 #> #> Step 4 (declare step): dplyr::mutate(income = noise^2) ------------------------- #> #> Added variable: income #> min median mean max sd N_missing N_unique #> 0.00 0.47 0.97 7.64 1.24 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 #> -1.75 -0.20 -0.07 2.54 0.96 0 100 #> #> Step 2 (potential outcomes): my_potential_outcomes ----------------------------- #> #> Added variable: Y_Z_0 #> min median mean max sd N_missing N_unique #> -1.75 -0.20 -0.07 2.54 0.96 0 100 #> #> Added variable: Y_Z_1 #> min median mean max sd N_missing N_unique #> -3.68 2.04 1.95 6.11 1.97 0 100 #> #> Step 3 (declare step): dplyr::mutate(income = noise^2) ------------------------- #> #> Added variable: income #> min median mean max sd N_missing N_unique #> 0.00 0.46 0.91 6.43 1.12 0 100 #> #> Step 4 (assignment): my_assignment --------------------------------------------- #> #> Added variable: Z #> 0 1 NA #> Frequency 50 50 0 #> Proportion 0.50 0.50 0.00 #> #> Added variable: Z_cond_prob #> 0.5 NA #> Frequency 100 0 #> Proportion 1.00 0.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 #> -3.37 -0.25 -0.21 2.71 1.07 0 100 #> #> Step 2 (potential outcomes): my_potential_outcomes ----------------------------- #> #> Added variable: Y_Z_0 #> min median mean max sd N_missing N_unique #> -3.37 -0.25 -0.21 2.71 1.07 0 100 #> #> Added variable: Y_Z_1 #> min median mean max sd N_missing N_unique #> -2.78 1.63 1.74 7.79 2.03 0 100 #>