completer function

completer

completer

Create imputed dataset(s) using transcan and aregImpute objects

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

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.

Returns

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

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

## Not run: 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 # To get a stacked data frame of all completed datasets use # do.call(rbind, completer(myareg, data=mydata)) # or use rbindlist in data.table ## End(Not run)

Author(s)

Yong-Hao Pua, Singapore General Hospital