completer | R Documentation |
Create imputed dataset(s) using transcan
and aregImpute
objects
completer(a, nimpute, oneimpute = FALSE, mydata)
a |
An object of class |
nimpute |
A numeric vector between 1 and |
oneimpute |
A logical vector. When set to |
mydata |
A data frame in which its missing values will be imputed. |
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.
A single or a list of completed dataset(s).
Yong-Hao Pua, Singapore General Hospital
## 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.