srtDataSimulation {epts} | R Documentation |
Simulate Simple Randomized Trial (SRT) Data
Description
This function simulates a Simple Randomized Trial (SRT), with multiple intervention arms, pre-test and post-test scores, and individual-level attrition. No clustering or hierarchical structure is assumed.
Usage
srtDataSimulation(ni, tpi, np, sigma, B0, es, seed, attritionrates, covariates)
Arguments
ni |
The number of intervention groups excluding the control group. |
tpi |
The proportions (in percent) assigned to each group, with the first value for the control group followed by the intervention groups. Must sum to 100. It should be specified as a numeric vector of length ni + 1. |
np |
The total number of participants. |
sigma |
The standard deviation of individual-level error for the post-test score. |
B0 |
The intercept term in the model. |
es |
The standardized effect sizes for each intervention group. It should be specified as a numeric vector. |
seed |
The random seed for reproducibility. |
attritionrates |
The attrition rates for each group, including the control group. It should be specified as a numeric vector of length ni + 1. |
covariates |
List of covariate specifications. Each element should be a list with the following fields:
|
Value
A data.frame
containing:
- ID
Participant ID
- interventions
Intervention assignment (0 = control, 1 to
ni
= intervention groups)- covariates
Simulated covariates
- posttest
Posttest score (NA if participant attrited)
Examples
covariates <- list(
list(name = "pretest", type = "continuous", sd = 1, coefficient = 1.7),
list(name = "gender", type = "categorical", levels = c("Male", "Female"),
probs = c(0.3, 0.7), reference = "Male", coefficients = list(B = -0.5)),
list(name = "ethnicity", type = "categorical", levels = c("White", "Black", "Asian"),
probs = c(0.3, 0.3, 0.4), reference = "White", coefficients = list(B = 1.02, C = 1.3))
)
srtdata <- srtDataSimulation(ni = 3, np = 1000, tpi = c(30, 30, 20, 20),
sigma = 1, B0 = 1.45, es = c(0.2, 0.3, 0.1), seed = 1234,
attritionrates = c(0.1, 0.1, 0.1, 0), covariates = covariates)
head(srtdata)