Decision Tree Imputation
Imputation based on CART models or Random Forests.
impute_cart(dat, formula, add_residual = c("none", "observed", "normal"), cp, na_action = na.rpart, ...)
impute_rf(dat, formula, add_residual = c("none", "observed", "normal"), na_action = na.omit, ...)
[data.frame], with variables to be imputed and their predictors.
[formula]imputation model description (see Details below).
[character]Type of residual to add.
"normal"means that the imputed value is drawn from
sdare estimated from the model's residuals (
mushould equal zero in most cases). If
add_residual = "observed", residuals are drawn (with replacement) from the model's residuals. Ignored for non-numeric predicted variables.
- The complexity parameter used to
prunethe CART model. If omitted, no pruning takes place. If a single number, the same complexity parameter is used for each imputed variable. If of length
#of variables imputed, the complexity parameters used must be in the same order as the predicted variables in the
[function]what to do with missings in training data. By default cases with missing values in predicted or predictors are omitted (see `Missings in training data').
- further arguments passed to
Formulas are of the form
IMPUTED_VARIABLES ~ MODEL_SPECIFICATION [ | GROUPING_VARIABLES ]
The left-hand-side of the formula object lists the variable or variables to be imputed. Variables on the right-hand-side are used as predictors in the CART or random forest model.
If grouping variables are specified, the data set is split according to the values of those variables, and model estimation and imputation occur independently for each group.
dplyr::group_by is also supported. If groups are
defined in both the formula and using
dplyr::group_by, the data is
grouped by the union of grouping variables. Any missing value in one of the
grouping variables results in an error.
CART imputation by
impute_cart can be used for numerical,
categorical, or mixed data. Missing values are estimated using a
Classification and Regression Tree as specified by Breiman, Friedman and
Olshen (1984). This means that prediction is fairly robust agains missingess
Random Forest imputation with
impute_rf can be used for numerical,
categorical, or mixed data. Missing values are estimated using a Random Forest
model as specified by Breiman (2001).
Breiman, L., Friedman, J., Stone, C.J. and Olshen, R.A., 1984. Classification and regression trees. CRC press.
Breiman, L., 2001. Random forests. Machine learning, 45(1), pp.5-32.