View source: R/trans_imputation_tree.R
| imputation_tree | R Documentation |
Impute one target column from a set of source columns using a decision tree.
imputation_tree(target, sources = NULL, method = c("median", "mean"))
target |
target column to impute |
sources |
optional vector of predictor column names (default: all supported columns except |
method |
initial imputation method for numeric source columns: "median" or "mean" |
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.
returns an object of class imputation_tree
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.
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))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.