datlist_create: Creates Objects of Class 'datlist' or 'nested.datlist'

Description Usage Arguments Value Author(s) Examples

Description

Creates objects of class datlist or nested.datlist.

The functions nested.datlist2datlist and datlist2nested.datlist provide list conversions for imputed datasets.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
datlist_create(datasets)

nested.datlist_create(datasets)

## S3 method for class 'datlist'
print(x, ...)

## S3 method for class 'nested.datlist'
print(x, ...)

nested.datlist2datlist(datlist)

datlist2nested.datlist(datlist, Nimp)

Arguments

datasets

For datlist_create: List of datasets, objects of class imputationList, mids, mids.1chain,

For nested.datlist_create: nested list of datasets, NestedImputationList, mids.nmi

x

Object of classes datlist or nested.datlist

datlist

Object of classes datlist, imputationList, nested.datlist or NestedImputationList.

Nimp

Vector of length 2 containing numbers of between and within imputations.

...

Further arguments to be passed

Value

Object of class datlist or nested.datlist

Author(s)

Alexander Robitzsch

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
## Not run: 
## The function datlist_create is currently defined as
function (datasets) 
{
    class(datasets) <- "datlist"
    return(datasets)
  }
  
#############################################################################
# EXAMPLE 1: Create object of class datlist
#############################################################################

library(BIFIEsurvey)
data(data.timss2 , package="BIFIEsurvey" )
datlist <- data.timss2      

# class datlist
obj1 <- datlist_create(data.timss2)

#############################################################################
# EXAMPLE 2: Multiply imputed datasets: Different object classes
#############################################################################

library(mice)
data(nhanes2, package="mice")
set.seed(990)

# nhanes2 data imputation
imp1 <- mice.1chain( nhanes2 , burnin=5 , iter=25 , Nimp=5 )
# object of class datlist
imp2 <- mids2datlist(imp1)
# alternatively, one can use datlist_create
imp2b <- datlist_create(imp1)
# object of class imputationList
imp3 <- mitools::imputationList(imp2)
# retransform object in class datlist
imp2c <- datlist_create(imp3)
str(imp2c)

#############################################################################
# EXAMPLE 3: Nested multiply imputed datasets
#############################################################################

library(BIFIEsurvey)
data(data.timss2 , package="BIFIEsurvey" )
datlist <- data.timss2      
   # list of 5 datasets containing 5 plausible values

#** define imputation method and predictor matrix
data <- datlist[[1]]
V <- ncol(data)
# variables
vars <- colnames(data)
# variables not used for imputation
vars_unused <- scan.vec("IDSTUD TOTWGT  JKZONE  JKREP" )

#- define imputation method
impMethod <- rep("norm" , V )
names(impMethod) <- vars
impMethod[ vars_unused ] <- ""

#- define predictor matrix
predM <- matrix( 1 , V , V )
colnames(predM) <- rownames(predM) <- vars
diag(predM) <- 0
predM[ , vars_unused ] <- 0

# object of class nmi
imp1 <- mice.nmi( datlist , imputationMethod=impMethod , predictorMatrix=predM, 
                m=4 , maxit=3 )
# object of class nested.datlist
imp2 <- mids2datlist(imp1)
# object of class NestedImputationList
imp3 <- NestedImputationList(imp2)
# redefine class nested.datlist
imp4 <- nested.datlist_create(imp3)

#############################################################################
# EXAMPLE 4: Conversions between nested lists of datasets and lists of datasets
#############################################################################

library(BIFIEsurvey)
data(data.timss4 , package="BIFIEsurvey" )
datlist <- data.timss4

# object of class nested.datlist
datlist1a <- nested.datlist_create(datlist)
# object of class NestedImputationList
datlist1b <- NestedImputationList(datlist)

# conversion to datlist
datlist2a <- nested.datlist2datlist(datlist1a)  # class datlist
datlist2b <- nested.datlist2datlist(datlist1b)  # class imputationList

# convert into a nested list with 2 between nests and 10 within nests
datlist3a <- datlist2nested.datlist(datlist2a, Nimp=c(2,10) )
datlist3b <- datlist2nested.datlist(datlist2b, Nimp=c(4,5) )

## End(Not run)  


Search within the miceadds package
Search all R packages, documentation and source code

Questions? Problems? Suggestions? or email at ian@mutexlabs.com.

Please suggest features or report bugs with the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.