Mean imputation

Share:

Description

Mean imputation

Usage

1
meanimp(mat)

Arguments

mat

A numerical matrix

Details

The function implements the unconditional mean imputation on a numerical matrix with missing values, substituting to each missing value the arithmetic mean of the corresponding variable

Value

The imputed matrix

Author(s)

Alessandro Barbiero, Giancarlo Manzi, Pier Alda Ferrari

See Also

modeimp, medianimp

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
set.seed(1)
n<-10
m<-3
mat<-matrix(rnorm(n*m),n,m)
matm<-mat
matm[1,1]<-NA
matm[2,2:3]<-NA
# matrix with missing values
matm
# imputed matrix
meanimp(mat)
# original matrix with no missing values
mat