impute: Impute New Data With Existing Models

Description Usage Arguments Details Value Examples

View source: R/impute.R

Description

Impute data using the information from an existing miceDefs object.

Usage

1
2
3
4
5
6
7
impute(
  data,
  miceObj,
  datasets = 1:miceObj$callParams$m,
  iterations = miceObj$callParams$maxiter,
  verbose = TRUE
)

Arguments

data

The data to be imputed. Must have all columns used in the imputation of miceDefs.

miceObj

A miceDefs object created by miceRanger().

datasets

A numeric vector specifying the datasets with which to impute data. See details for more information.

iterations

The number of iterations to run. By default, the same as the number of iterations currently in miceObj.

verbose

should progress be printed?

Details

This capability is experimental, but works well in benchmarking. The original data and random forests (if returnModels = TRUE) are returned when miceRanger is called. These models can be recycled to impute a new dataset in the same fashion as miceRanger, by imputing each variable over a series of iterations. Each dataset created in miceObj can be thought of as a different imputation mechanism, with different initialized values and a different associated random forests. Therefore, it is necessary to choose the datasets which will be used to impute the data. When mean matching a numeric variable, the candidate values are drawn from the original data passed to miceRanger, not the data passed to this function.

Value

An object of class impDefs, which contains information about the imputation process.

callParams

The parameters of the object.

data

The original data provided by the user.

naWhere

Logical index of missing data, having the same dimensions as data.

missingCounts

The number of missing values for each variable.

imputedData

A list of imputed datasets.

Examples

1
2
3
4
5
ampDat <- amputeData(iris)
miceObj <- miceRanger(ampDat,1,1,returnModels=TRUE,verbose=FALSE)

newDat <- amputeData(iris)
newImps <- impute(newDat,miceObj)

miceRanger documentation built on Sept. 6, 2021, 5:07 p.m.