impute: Impute Missing Values in Dataset

View source: R/impute.R

imputeR Documentation

Impute Missing Values in Dataset

Description

Imputes blanks and NAs in dataset by various methods.

Usage

impute(
  data,
  method = "mice",
  mice_method = NULL,
  pred_ignore = c(),
  impute_ignore = c(),
  pred_matrix = NULL,
  impute_outlier = Inf,
  seed = 628
)

Arguments

data

dataset to be analysed.

method

method of imputation. Possible methods are "mice" or "mean/mode".

mice_method

the method of imputation used by the mice package. Only required if method = "mice".

pred_ignore

columns in dataset to be not used in data imputation process. Only required if method = "mice".

impute_ignore

columns in dataset to be not imputed.

pred_matrix

optional pre-defined prediction matrix to derive the imputed values when using the "mice" method.

impute_outlier

a numeric where values which are impute_outlier standard deviations away from the mean will be imputed. By default, set to Inf, hence no outliers are imputed.

seed

seed for set.seed.

Details

Imputes missing values (blanks or NAs) in dataset. There are two possible methods of imputation. If method = "mean/mode", then all missing values in numeric variables will be imputed with its mean and all missing values in factor variables will be imputed with its mode.

If method = "mice", then imputation will be performed using the mice package. The imputation method performed by mice can be selected using the mice_method parameter. A single method can be specified, which will be applied to all eligible variables in the dataset, or a vector of methods for each variable (including variables listed in impute_ignore) can be specified. If the mice_method parameter is not used, then the default methods selected by mice will be used. The pred_ignore parameter is only applicable when using the "mice" method. This specifies which variables should not be used in the data imputation process.

Value

imputed data.table.

Examples

## Not run: 
if(interactive()){
 data(property_prices)
 impute(property_prices)
 }

## End(Not run)

Nanoputian628/nano documentation built on Oct. 30, 2023, 3:28 p.m.