missRanger.Rd
missRanger
is a modified imputation function of
missRanger
in 'missRanger' package. The only difference is that the
disjunctive imputed dataset is also returned (with categorical columns in
form of one-hot probability vector).
Uses the "ranger" package (Wright & Ziegler) to do fast missing value
imputation by chained random forests, see Stekhoven & Buehlmann and Van
Buuren & Groothuis-Oudshoorn. Between the iterative model fitting, it offers
the option of predictive mean matching. This firstly avoids imputation with
values not present in the original data (like a value 0.3334 in a 0-1 coded
variable). Secondly, predictive mean matching tries to raise the variance in
the resulting conditional distributions to a realistic level. This allows to
do multiple imputation when repeating the call to missRanger().
The iterative chaining stops as soon as maxiter
is reached or if the
average out-of-bag estimate of performance stops improving. In the latter
case, except for the first iteration, the second last (i.e. best) imputed
data is returned.
A note on `mtry`: Be careful when passing a non-default `mtry` to `ranger()`
because the number of available covariables might be growing during the first
iteration, depending on the missing pattern. Values NULL
(default) and
1 are safe choices. Additionally, recent versions of `ranger()` allow `mtry`
to be a single-argument function of the number of available covariables, e.g.
`mtry = function(m) max(1, m
missRanger(
data,
formula = . ~ .,
pmm.k = 0L,
maxiter = 10L,
seed = NULL,
verbose = 1,
returnOOB = FALSE,
case.weights = NULL,
col_cat = c(),
...
)
A data.frame
or tibble
with missing values to
impute.
A two-sided formula specifying variables to be imputed (left hand side) and variables used to impute (right hand side). Defaults to . ~ ., i.e. use all variables to impute all variables. If e.g. all variables (with missings) should be imputed by all variables except variable "ID", use . ~ . - ID. Note that a "." is evaluated separately for each side of the formula. Further note that variables with missings must appear in the left hand side if they should be used on the right hand side.
Number of candidate non-missing values to sample from in the predictive mean matching steps. 0 to avoid this step.
Maximum number of chaining iterations.
Integer seed to initialize the random generator.
Controls how much info is printed to screen. 0 to print
nothing. 1 (default) to print a "." per iteration and variable, 2 to print
the OOB prediction error per iteration and variable (1 minus R-squared for
regression).
Furthermore, if verbose
is positive, the variables used for imputation
are listed as well as the variables to be imputed (in the imputation order).
This will be useful to detect if some variables are unexpectedly skipped.
Logical flag. If TRUE, the final average out-of-bag prediction error is added to the output as attribute "oob". This does not work in the special case when the variables are imputed univariately.
Vector with non-negative case weights.
Column index of categorical variables.
Arguments passed to ranger()
. If the data set is large,
better use less trees (e.g. num.trees = 20
) and/or a low value of
sample.fraction
.
The following arguments are e.g. incompatible with ranger
:
write.forest
, probability
, split.select.weights
,
dependent.variable.name
, and classification
.
ximp
An imputed data.frame
.
ximp.disj
A disjunctive imputed data.frame
.
For example if Y7 has levels a and b, then in ximp.disj
the column
Y7_1 corresponds to the probability of Y7=a.
Wright, M. N. & Ziegler, A. (2016). ranger: A Fast Implementation of Random Forests for High Dimensional Data in C++ and R. Journal of Statistical Software, in press. <arxiv.org/abs/1508.04409>.
Stekhoven, D.J. and Buehlmann, P. (2012). 'MissForest - nonparametric missing value imputation for mixed-type data', Bioinformatics, 28(1) 2012, 112-118. https://doi.org/10.1093/bioinformatics/btr597.
Van Buuren, S., Groothuis-Oudshoorn, K. (2011). mice: Multivariate Imputation by Chained Equations in R. Journal of Statistical Software, 45(3), 1-67. http://www.jstatsoft.org/v45/i03/