sim_trial | R Documentation |
Simulate a single cross-sectional trial
sim_trial( n_subjects = 40, sigma_u = 0.5, group_allocation = list(control = 0.5, treatment = 0.5), random_allocation = TRUE, n_goals = NULL, n_goals_range = c(3, 6), n_goals_prob = NULL, sigma_e = 0.5, delta = 0.3, mean_control_response = -0.3, weight_type = "unweighted", n_levels = 5, score_dist = "norm", centre = 0 )
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 |
n_goals |
The exact number of goals for each subject. |
n_goals_range |
A vector defining the minimum and maximum number of goals per subjects. Randomly samples the range of goals with uniform probability. |
n_goals_prob |
A named list with element |
sigma_e |
Standard deviation of the goal-level random effect, i.e. the random error of each latent goal score. |
delta |
The size of the treatment effect. |
mean_control_response |
The mean response in the control group. |
weight_type |
The type of weights to apply. See 'Details'. |
n_levels |
The number of levels to use. Defaults to the traditional 5 levels. |
score_dist |
The distribution by which scores should be approximated. The default "norm" will return thresholds which approximate a standard normal distribution. Choosing "unif" will return thresholds which approximate a uniform distribution. |
centre |
The centre of the normal distribution from which the thresholds are taken. |
A data frame with a row per trial (numbered 1 to n_sim
) with
list column data
containing the simulated data.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.