impute_mode {missMethods}R Documentation

Mode imputation

Description

Impute an observed mode value for every missing value

Usage

impute_mode(ds, type = "columnwise", convert_tibble = TRUE)

Arguments

ds

A data frame or matrix with missing values.

type

A string specifying the values used for imputation; one of: "columnwise", "rowwise", "total", "Two-Way" or "Winer" (see details).

convert_tibble

If ds is a tibble, should it be converted (see section A note for tibble users).

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.

Value

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

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

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)

[Package missMethods version 0.4.0 Index]