imputationList: Constructor for imputationList objects

Description Usage Arguments Details Value Examples

Description

Create and update imputationList objects to be used as input to other MI routines.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
imputationList(datasets,...)
## Default S3 method:
imputationList(datasets,...)
## S3 method for class 'character'
imputationList(datasets,dbtype,dbname,...)
## S3 method for class 'imputationList'
update(object,...)
## S3 method for class 'imputationList'
rbind(...)
## S3 method for class 'imputationList'
cbind(...)

Arguments

datasets

a list of data frames corresponding to the multiple imputations, or a list of names of database tables or views

dbtype

"ODBC" or a database driver name for DBI::dbDriver()

dbname

Name of the database

object

An object of class imputationList

...

Arguments tag=expr to update will create new variables tag by evaluating expr in each imputed dataset. Arguments to imputationList() are passed to the database driver

Details

When the arguments to imputationList() are character strings a database-based imputation list is created. This can be a database accessed through ODBC with the RODBC package or a database with a DBI-compatible driver. The dbname and ... arguments are passed to dbConnect() or odbcConnect() to create a database connection. Data are read from the database as needed.

For a database-backed object the update() method creates variable definitions that are evaluated as the data are read, so that read-only access to the database is sufficient.

Value

An object of class imputationList or DBimputationList

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
## Not run: 
## CRAN doesn't like this example
data.dir <- system.file("dta",package="mitools")
files.men <- list.files(data.dir,pattern="m.\\.dta$",full=TRUE)
men <- imputationList(lapply(files.men, foreign::read.dta))
files.women <- list.files(data.dir,pattern="f.\\.dta$",full=TRUE)
women <- imputationList(lapply(files.women, foreign::read.dta))
men <- update(men, sex=1)
women <- update(women,sex=0)
all <- rbind(men,women)
all <- update(all, drinkreg=as.numeric(drkfre)>2)
all

## End(Not run)

Example output

Warning messages:
1: In FUN(X[[i]], ...) : value labels ('mis') for 'mdrkfre' are missing
2: In FUN(X[[i]], ...) : value labels ('mis') for 'mdrkfre' are missing
3: In FUN(X[[i]], ...) : value labels ('mis') for 'mdrkfre' are missing
4: In FUN(X[[i]], ...) : value labels ('mis') for 'mdrkfre' are missing
5: In FUN(X[[i]], ...) : value labels ('mis') for 'mdrkfre' are missing
Warning messages:
1: In FUN(X[[i]], ...) : value labels ('mis') for 'mdrkfre' are missing
2: In FUN(X[[i]], ...) : value labels ('mis') for 'mdrkfre' are missing
3: In FUN(X[[i]], ...) : value labels ('mis') for 'mdrkfre' are missing
4: In FUN(X[[i]], ...) : value labels ('mis') for 'mdrkfre' are missing
5: In FUN(X[[i]], ...) : value labels ('mis') for 'mdrkfre' are missing
MI data with 5 datasets
Call: rbind(deparse.level, ...)

mitools documentation built on May 2, 2019, 8:52 a.m.