Function to preprocess the data and obtain the design matrices corresponding to a model with just interaction of the covariates with the treatment, to a model with just the main effects and to a model just with the covariates and one-hot encoding.
preprocess(trt, subgr, covars, data)
Arguments
trt: (string)
the treatment variable name. The treatment variable must be a factor with 2 levels where the first level is the control and the second one the treatment.
subgr: (character)
vector with the name of the subgroup variables from which we want to obtain the subgroup treatment effect.
covars: (character)
vector with the name of the variables that we want to include in the model. The subgr variables have to be included here.
data: (data frame)
the data frame with the variables.
Returns
List with design_ia, design_main, design_dummy, subgr_names.