Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

write.datlist

Write a List of Multiply Imputed Datasets


Description

Writes a list of multiply imputed datasets.

Usage

write.datlist(datlist, name, include.varnames=TRUE, type="csv2",
     separate=TRUE, Mplus=FALSE, round=NULL, Rdata=TRUE,
     subdir=TRUE, ...)

Arguments

datlist

List of imputed datasets. Can also be an object of class mids, mids.1chain or imputationList

name

Name of files to be saved

include.varnames

Logical indicating whether variables should be saved

type

File type of datasets to be saved, see save.data.

separate

Logical indicating whether imputed datasets should be written in separate files.

Mplus

Logical indicating whether files should be written for usage in Mplus software

round

Number of digits to round after decimal. The default is no rounding.

Rdata

Logical indicating whether datlist should also be saved in R binary format.

subdir

Logical indicating whether results should be written into a subdirectory.

...

Further arguments to be passed to save.data.

See Also

See also mice::mids2mplus, mice::mids2spss and write.mice.imputation for writing objects of class mids.

See also Amelia::write.amelia for writing imputed datasets in Amelia.

Examples

## Not run: 
#############################################################################
# EXAMPLE 1: Write data list imputed in mice
#############################################################################

data(data.ma01)
dat <- as.matrix(data.ma01)

# start with empty imputation
imp0 <- mice::mice( dat, maxit=0)

# modify predictor matrix
predM <- imp0$predictorMatrix
predM[, c("idschool", "idstud" ) ] <- 0
# modify imputation method
impMeth <- imp0$method
impMeth[ impMeth=="pmm" ] <- "norm"

# do imputations in mice
imp <- mice::mice( dat, predictorMatrix=predM, method=impMeth, m=3, maxit=4 )

# write imputed data in format "csv2" and round after 4 digits
write.datlist( datlist=imp, name="mice_imp_csv2", round=4 )
# write imputed data in R binary format
write.datlist( datlist=imp, name="mice_imp_Rdata", type="Rdata")
# write data for Mplus usage
write.datlist( datlist=imp, name="mice_imp_Mplus", Mplus=TRUE, round=5)

## End(Not run)

miceadds

Some Additional Multiple Imputation Functions, Especially for 'mice'

v3.11-6
GPL (>= 2)
Authors
Alexander Robitzsch [aut,cre] (<https://orcid.org/0000-0002-8226-3132>), Simon Grund [aut] (<https://orcid.org/0000-0002-1290-8986>), Thorsten Henke [ctb]
Initial release
2021-01-21 11:48:47

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.