Imputation of most likely value within the class
Method 2lonly.mean
replicates the most likely value within
a class of a second-level variable. It works for numeric and
factor data. The function is primarily useful as a quick fixup for
data in which the second-level variable is inconsistent.
mice.impute.2lonly.mean(y, ry, x, type, wy = NULL, ...)
y |
Vector to be imputed |
ry |
Logical vector of length |
x |
Numeric design matrix with |
type |
Vector of length |
wy |
Logical vector of length |
... |
Other named arguments. |
Observed values in y
are averaged within the class, and
replicated to the missing y
within that class.
This function is primarily useful for repairing incomplete data
that are constant within the class, but vary over classes.
For numeric variables, mice.impute.2lonly.mean()
imputes the
class mean of y
. If y
is a second-level variable, then
conventionally all observed y
will be identical within the
class, and the function just provides a quick fix for any
missing y
by filling in the class mean.
For factor variables, mice.impute.2lonly.mean()
imputes the
most frequently occuring category within the class.
If there are no observed y
in the class, all entries of the
class are set to NA
. Note that this may produce problems
later on in mice
if imputation routines are called that
expects predictor data to be complete. Methods designed for
imputing this type of second-level variables include
mice.impute.2lonly.norm
and
mice.impute.2lonly.pmm
.
Vector with imputed data, same type as y
, and of length
sum(wy)
Gerko Vink, Stef van Buuren, 2019
Van Buuren, S. (2018). Flexible Imputation of Missing Data. Second Edition. Boca Raton, FL.: Chapman & Hall/CRC Press.
Other univariate-2lonly:
mice.impute.2lonly.norm()
,
mice.impute.2lonly.pmm()
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.