View source: R/crtDataSimulation.R
crtDataSimulation | R Documentation |
This function simulates a multiple intervention arms CRT data. The model includes intervention and pre-test scores as covariates.
crtDataSimulation(
ni,
nstreated,
np,
ns,
sigma,
ICC,
B0,
es,
seed,
attritionrates,
covariates
)
ni |
The number of intervention groups excluding the control group. |
nstreated |
The number of schools in each group, including the control group. It should be specified as an integer vector of length ni + 1. |
np |
The number of pupils per school. |
ns |
The total number of schools. |
sigma |
The standard deviation of the individual-level error. |
ICC |
The intra-class correlation coefficient. |
B0 |
The intercept of 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 proportion of attrition 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:
|
A data.frame
containing:
Unique pupil ID
School ID
Intervention group (0 = control, 1 to ni
for interventions)
Simulated covariates
Simulated posttest scores (NA if attrited)
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))
)
crtdata <- crtDataSimulation(ni = 3, ns = 10, np = 100, nstreated = c(2, 3, 2, 3),
sigma = 1, ICC = 0.1, B0 = 1.45, es = c(0.1, 0.2, 0.5),
seed = 1234, attritionrates = c(0, 0.1, 0.2, 0.1), covariates = covariates)
head(crtdata)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.