Learn R Programming

MixtureMissing (version 3.0.3)

mean_impute: Mean Imputation

Description

Replace missing values of data set by the mean of other observed values.

Usage

mean_impute(X)

Value

A complete data matrix with missing values imputed accordingly.

Arguments

X

An \(n\) x \(d\) matrix or data frame where \(n\) is the number of observations and \(d\) is the number of columns or variables. Alternately, X can be a vector of \(n\) observations.

References

Schafer, J. L. and Graham, J. W. (2002). Missing data: our view of the state of the art. Psychological Methods, 7(2):147–177.

Little, R. J. A. and Rubin, D. B. (2020). Statistical analysis with missing data. Wiley Series in Probability and Statistics. Wiley, Hoboken, NJ, 3rd edition

Examples

Run this code

X <- matrix(nrow = 6, ncol = 3, byrow = TRUE, c(
  NA,  2,  2,
   3, NA,  5,
   4,  3,  2,
  NA, NA,  3,
   7,  2, NA,
  NA,  4,  2
))


mean_impute(X)

Run the code above in your browser using DataLab