Learn R Programming

RMCLab (version 0.1.0)

mode_impute: Mode imputation

Description

Perform mode imputation for discrete data. In case of multiple modes in a given column, one of them is selected at random for each missing cell.

Usage

mode_impute(X, values = NULL)

Value

An object of class "mode_impute" with the following components:

modes

a list containing the mode(s) of the observed values for each variable.

X

a numeric matrix containing the completed (i.e., imputed) data matrix.

The class structure is still experimental and may change in the future. Use the accessor function get_completed() to extract the completed (i.e., imputed) data matrix.

Arguments

X

a matrix or data frame of discrete data with missing values.

values

an optional numeric vector giving the possible values. Currently, the possible values are assumed to be the same for all columns. If NULL, the unique values of the observed parts of X are used.

Author

Andreas Alfons

See Also

median_impute()

Examples

Run this code
# toy example derived from MovieLens 100K dataset
data("MovieLensToy")
# mode imputation
fit <- mode_impute(MovieLensToy, values = 1:5)
# extract completed matrix
X_hat <- get_completed(fit)
head(X_hat)

Run the code above in your browser using DataLab