CleanData.RdThis function performs a series of data cleaning and preprocessing steps to ensure the data is suitable for analysis.
CleanData(
  data,
  y,
  d,
  z,
  x_ymodel = NULL,
  x_smodel = NULL,
  ER = ER,
  side = side
)A data.frame containing the data to be cleaned.
Name of the dependent variable (character; numeric).
Name of the treatment received variable (character; numeric 0 or 1).
Name of the treatment assigned variable (character; numeric 0 or 1).
Names of the covariates to include in the Y-model (character vector, optional).
Names of the covariates to include in the S-model (character vector, optional).
A list containing the cleaned dataset and relevant metadata:
N: The number of observations after cleaning.
P_ymodel The number of covariates in the Y-model after cleaning.
P_smodel The number of covariates in the S-model after cleaning.
Z The treatment assigned vector (instrument variable).
D The treatment received vector (treatment variable).
Y The dependent variable vector (outcome variable).
X_ymodel The cleaned covariate matrix in the Y-model (including intercept).
X_smodel The cleaned covariate matrix in the S-model (including intercept).