cleanData {imt} | R Documentation |
Cleans and prepares data for analysis
Description
This function performs a series of data cleaning and preprocessing steps to ensure the data is suitable for analysis. This includes:
Missing data handling
Variable type checks
Collinearity and zero-variance feature removal
Usage
cleanData(data, y, treatment, x = NULL, binary = FALSE)
Arguments
data |
A data.frame containing the data to be cleaned. |
y |
Name of the dependent variable (character). |
treatment |
Name of the treatment variable (character, should be logical). |
x |
Names of the covariates to include in the model (character vector, optional). |
binary |
Should the dependent variable be treated as binary? Default is FALSE |
Value
A list containing the cleaned dataset and relevant metadata:
-
N
: The number of observations after cleaning. -
K
The number of covariates after cleaning. -
X
The cleaned covariate matrix. -
treat_vec
: Treatment vector as integers (1 for TRUE, 0 for FALSE). -
Y
: The dependent variable vector.