sim_subjects | R Documentation |
Simulate a number of subjects with subject-level random effects, and randomly assign them to groups.
sim_subjects( n_subjects = 100, sigma_u = 0.5, group_allocation = list(control = 0.5, treatment = 0.5), random_allocation = TRUE )
n_subjects |
Number of subjects. |
sigma_u |
Standard deviation of the subject-level random effect. |
group_allocation |
A named list of groups and their probability of assignment. By default, will give equal probability to "control" and "treatment" groups. If NULL, will returns subjects without groups. |
random_allocation |
Logical. If TRUE (default), randomly assigns to
groups based on probabilities in |
A data frame with a row for each subject.
sim_subjects(n_subjects = 20) sim_subjects( group_allocation = list("placebo" = 1/2, "1x dose" = 1/4, "2x dose" = 1/4) ) # If using non-random group allocation, `n_subjects` must be able to be # divided using the given `group_allocation` sim_subjects( n_subjects = 99, group_allocation = list("placebo" = 1/3, "1x dose" = 1/3, "2x dose" = 1/3), random_allocation = FALSE )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.