imputationMice: Multiple Imputation by Chained Equation

View source: R/imputationMice.R

imputationMiceR Documentation

Multiple Imputation by Chained Equation

Description

Imputed missing data using mice::mice(). This function implements some additional functionality to mice imputation to be performed by row rather than by column.

Usage

imputationMice(
  data,
  by.row = FALSE,
  row.range = 1:nrow(data),
  col.range = 1:ncol(data),
  mice.method = "pmm",
  m = 5,
  mice.action = 1L,
  ...
)

Arguments

data

a matrix-like R object with two dimensions containing the data to be passed into mice().

by.row

a logical value indicating whether the data should be imputed by row rather than by column (default).

row.range

a numeric vector containing the row numbers to be included in the MICE algorithm.

col.range

a numeric vector containing the column numbers to be included in the MICE algorithm.

mice.method

Can be either a single string, or a vector of strings with length length(blocks), specifying the imputation method to be used for each column in data. If specified as a single string, the same method will be used for all blocks. The default imputation method (when no argument is specified) depends on the measurement level of the target column, as regulated by the defaultMethod argument. Columns that need not be imputed have the empty method "". See details. (from mice documentation. See ?mice for all mice methods).

m

Numeric value passed to mice(). Number of multiple imputations. The default is m = 5.

mice.action

A numeric vector or a keyword to be passed into mice::complete(). Numeric values between 1 and data$m return the data with imputation number action filled in. The value of action = 0 return the original data, with missing values. action can also be one of the following keywords: "all", "long", "broad" and "repeated". See the Details section for the interpretation. The default is action = 1L returns the first imputed data set. (from mice documentation. See ?mice::complete).

...

Additional arguments to be passed to mice().

Value

Returns the passed data with missing values imputed.

Examples

# default mice
imputed_data <- imputationMice(data)

# mice performed by row, excluding the first column.
imputed_data_byrow <- imputationMice(data_byrow, by.row = TRUE,
col.range = 2:ncol(data_byrow))


Echinoidea/hooks-imputation documentation built on May 8, 2022, 4:39 p.m.