mstAddIntervention {epts} | R Documentation |
Add a New Intervention Group to Multisite Trial (MST)
Description
This function adds a new intervention group to an existing Multisite Trial (MST) dataset. It fits a linear mixed-effects model to the original data, then uses its estimates to generate post-test outcomes for the new group, incorporating random intercepts, slopes, and user-defined effect size.
Usage
mstAddIntervention(
originalData,
ns,
np,
es,
attritionrate,
intper,
outcome,
interventions,
schoolsID,
pupilsID,
continuous_covariates,
categorical_covariates
)
Arguments
originalData |
A data frame containing the variables including outcome, predictors, the clustering variable, and the intervention for MST design. |
ns |
The number of schools to assign to the new intervention group. |
np |
The number of pupils per new school. |
es |
The standardized effect size for the new intervention group. |
attritionrate |
The proportion of pupils in the new group to drop due to attrition. |
intper |
Proportion of pupils per new school assigned to the Intervention group. |
outcome |
A string specifying the name of the column containing outcome variable (e.g., post-test scores). |
interventions |
A string specifying the name of the intervention assignment column. |
schoolsID |
A string specifying the name of the school ID column. |
pupilsID |
A string specifying the name of the pupil ID column. |
continuous_covariates |
A character vector specifying the names of continuous covariates. |
categorical_covariates |
A character vector specifying the names of categorical covariates (converted to factors). |
Details
The function:
Fits a linear mixed-effects model (
lmer
) with random slopes and intercepts using existing MST data.Simulates new schools and pupils, assigning intervention randomly by specified percentage.
Simulates attrition by removing post-test scores at random.
Value
A data.frame
containing the combined dataset with the newly added intervention group and simulated outcomes.
See Also
lmer
from the lme4 package
Examples
data(mst4armSimData)
new_mst5armData <- mstAddIntervention(originalData = mst4armSimData, ns = 2, np = 100, es = 0.3,
intper = 0.5, attritionrate = 0.1, outcome = "posttest", interventions = "interventions",
schoolsID = "schools", pupilsID = "pupils",
continuous_covariates = c("pretest"), categorical_covariates = c("gender", "ethnicity"))
head(new_mst5armData)