sim_treatment_effect | R Documentation |
Currently only simulates a uniform distribution of treatment effects, regardless of group allocation.
sim_treatment_effect(goals, delta = 0.3)
goals |
A data frame with a row for each goal. |
delta |
The size of the treatment effect. |
The same goals
data frame with the added treatment_fe
column.
library(dplyr) library(tidyr) library(purrr) # Generate some subjects and goals d <- sim_subjects(n_subjects = 40) %>% sim_goals(n_goals_range = c(1, 3)) # Apply treatment effects in one of two ways # Using purrr::map() d %>% mutate( goals = map( goals, ~sim_treatment_effect(., delta = 0.4) ) ) # Or using tidyr::unnest() on the goals column d %>% unnest(goals) %>% group_by(subject_id) %>% sim_treatment_effect(delta = 0.4)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.