Learn R Programming

daltoolbox (version 1.3.767)

imputation_tree: Tree-based predictive imputation

Description

Impute one target column from a set of source columns using a decision tree.

Usage

imputation_tree(target, sources = NULL, method = c("median", "mean"))

Value

returns an object of class imputation_tree

Arguments

target

target column to impute

sources

optional vector of predictor column names (default: all supported columns except target)

method

initial imputation method for numeric source columns: "median" or "mean"

Details

The method fits a tree with the observed values of the target column and uses the source columns as predictors. If source columns contain missing values, they are first completed with imputation_simple() so the tree can be trained and applied. The learned model imputes only the target column; source columns are preserved in the returned data.

References

Breiman, L., Friedman, J., Olshen, R., Stone, C. (1984). Classification and Regression Trees. Wadsworth.

van Buuren, S., Groothuis-Oudshoorn, K. (2011). mice: Multivariate Imputation by Chained Equations in R. Journal of Statistical Software, 45(3), 1-67.

Examples

Run this code
data(iris)
iris_na <- iris
iris_na$Sepal.Length[c(2, 10, 25)] <- NA

imp <- imputation_tree("Sepal.Length")
imp <- fit(imp, iris_na)
iris_imp <- transform(imp, iris_na)
summary(iris_imp$Sepal.Length)
sum(is.na(iris_imp$Sepal.Length))

Run the code above in your browser using DataLab