Learn R Programming

missMethods (version 0.2.0)

impute_mode: Mode imputation

Description

Impute an observed mode value for every missing value

Usage

impute_mode(ds, type = "columnwise")

Arguments

ds

A data frame or matrix with missing values.

type

One of: "columnwise", "rowwise", "total", "Two-Way" or "Winer" (see details).

Value

An object of the same class as ds with imputed missing values.

Details

This function behaves exactly like impute_mean. The only difference is that it imputes a mode instead of a mean. All types from impute_mean are also implemented for impute_mode. They are documented in impute_mean and apply_imputation.

A mode value of a vector x is a most frequent value of x. If this value is not unique, the first occurring mode value in x will be used as imputation value.

References

Beland, S., Pichette, F., & Jolani, S. (2016). Impact on Cronbach's \(\alpha\) of simple treatment methods for missing data. The Quantitative Methods for Psychology, 12(1), 57-73.

See Also

apply_imputation the workhorse for this function.

Other location parameter imputation functions: impute_mean(), impute_median()

Examples

Run this code
# NOT RUN {
ds <- data.frame(X = c(1:12, rep(8, 8)), Y = 101:120)
ds_mis <- delete_MCAR(ds, 0.2)
ds_imp <- impute_mode(ds_mis)
# }

Run the code above in your browser using DataLab