quickpred_ext: Create mice predictorMatrix including unordered factors...

View source: R/mice_quickpred_extension.R

quickpred_extR Documentation

Create mice predictorMatrix including unordered factors (extends mice::quickpred)

Description

quickpred creates a predictor matrix that suggests which variables should be used for multiple imputation. However, it does not yield meaningful information for (unordered) factors. This function returns the same as mice::quickpred for numeric and logical variables and binary factors, but excludes character vectors and tests the predictive power of each level of factors with more than two levels separately (through dummy coding). If the correlation exceeds 'mincor' for at least one level, the factor variable is used as a predictor.

Usage

quickpred_ext(
  data,
  mincor = 0.1,
  minpuc = 0,
  include = "",
  exclude = "",
  method = "pearson"
)

Arguments

data

Matrix or data frame with incomplete data.

mincor

A scalar, numeric vector (of size ncol(data)) or numeric matrix (square, of size ncol(data) specifying the minimum threshold(s) against which the absolute correlation in the data is compared.

minpuc

A scalar, vector (of size ncol(data)) or matrix (square, of size ncol(data) specifying the minimum threshold(s) for the proportion of usable cases.

include

A string or a vector of strings containing one or more variable names from names(data). Variables specified are always included as a predictor.

exclude

A string or a vector of strings containing one or more variable names from names(data). Variables specified are always excluded as a predictor.

method

A string specifying the type of correlation. Use 'pearson' (default), 'kendall' or 'spearman'. Can be abbreviated.

Value

A square binary matrix of size ncol(data).

Source

This function is based on the mice::quickpred function as available in mice v 3.11.4, written by Stef van Buuren. The code for dummy coding factor variables is based on psych::dummy.code, written by William Revelle

See Also

quickpred


LukasWallrich/rNuggets documentation built on Aug. 26, 2022, 11:03 a.m.