Learn R Programming

Hmisc (version 5.1-0)

completer: completer

Description

Create imputed dataset(s) using transcan and aregImpute objects

Usage

completer(a, nimpute, oneimpute = FALSE, mydata)

Value

      A single or a list of completed dataset(s).

Arguments

a

An object of class transcan or aregImpute

nimpute

A numeric vector between 1 and a$n.impute. For transcan object, this is set to 1. For aregImpute object, returns a list of nimpute datasets when oneimpute is set to FALSE (default).

oneimpute

A logical vector. When set to TRUE, returns a single completed dataset for the imputation number specified by nimpute

mydata

A data frame in which its missing values will be imputed.

Author

      Yong-Hao Pua, Singapore General Hospital

Details

Similar in function to mice::complete, this function uses transcan and aregImpute objects to impute missing data and returns the completed dataset(s) as a dataframe or a list. It assumes that transcan is used for single regression imputation.

Examples

Run this code
if (FALSE) {
mtcars$hp[1:5]    <- NA
mtcars$wt[1:10]   <- NA
myrform <- ~ wt + hp + I(carb)
mytranscan  <- transcan( myrform,  data = mtcars, imputed = TRUE,
  pl = FALSE, pr = FALSE, trantab = TRUE, long = TRUE)
myareg      <- aregImpute(myrform, data = mtcars, x=TRUE, n.impute = 5)
completer(mytranscan)                    # single completed dataset
completer(myareg, 3, oneimpute = TRUE)
# single completed dataset based on the `n.impute`th set of multiple imputation
completer(myareg, 3)
# list of completed datasets based on first `nimpute` sets of multiple imputation
completer(myareg)
# list of completed datasets based on all available sets of multiple imputation
}

Run the code above in your browser using DataLab