Statistical Inference for Multiply Imputed Datasets

Description

Statistical inference for multiply imputed datasets. See mitools::MIcombine or mice::pool for functions of the same functionality.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
pool_mi(qhat, u = NULL, se = NULL, dfcom = 1e+07, method = "smallsample")

## S3 method for class 'pool_mi'
summary(object, alpha=0.05, ...)

## S3 method for class 'pool_mi'
coef(object, ...)

## S3 method for class 'pool_mi'
vcov(object, ...)

Arguments

qhat

List of parameter vectors

u

List of covariance matrices

se

List of vector of standard errors. Either u or se must be provided.

dfcom

Degrees of freedom of statistical analysis

method

The default is the small sample inference ("smallsample"). Any other input provides large sample inference.

object

Object of class pool_mi

alpha

Confidence level

...

Further arguments to be passed

Value

Object of with similar output as produced by the mice::pool function.

Author(s)

Alexander Robitzsch

See Also

mitools::MIcombine, mice::pool, mitml::testEstimates

For statistical inference for nested multiply imputed datasets see NMIcombine.

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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
## Not run: 
#############################################################################
# EXAMPLE 1: Statistical inference for models based on imputationList
#############################################################################

library(mitools)
library(mice)
library(Zelig)
library(mitml)
library(lavaan)
library(semTools)
data(data.ma02)

# save dataset as imputation list
imp <- mitools::imputationList( data.ma02 )
# mids object
imp0 <- datlist2mids( imp )
# datlist object
imp1 <- datlist_create(data.ma02)

#--- apply linear model based on imputationList
mod <- with( imp , stats::lm( read ~ hisei + female ) )
#--- apply linear model for mids object
mod0 <- with( imp0 , stats::lm( read ~ hisei + female ) )
# extract coefficients
cmod <- mitools::MIextract( mod , fun = coef)
# extract standard errors
semod <- lapply( mod , FUN = function(mm){
    smm <- summary(mm)
    smm$coef[,"Std. Error"]
} )
# extract covariance matrix
vmod <- mitools::MIextract( mod , fun = vcov)

#*** pooling based on covariance matrices
res1 <- pool_mi( qhat=cmod , u = vmod )
summary(res1)
coef(res1)
vcov(res1)

#*** pooling based on standard errors
res2 <- pool_mi( qhat=cmod , se = semod )

#*** pooling with MIcombine
res3 <- mitools::MIcombine( results=cmod , variances=vmod )

#*** pooling with pool function in mice
res4 <- mice::pool( mod0 )

#*** analysis in Zelig
# convert datalist into object of class amelia
mi02 <- list( "imputations"=data.ma02)
class(mi02) <- "amelia"
res5 <- Zelig::zelig( read ~ hisei + female , model="ls" , data= mi02 )

#*** analysis in lavaan
lavmodel <- "
     read ~ hisei + female
     read ~~ a*read
     read ~ 1
     # residual standard deviation
     sde := sqrt(a)
       "
# analysis for first imputed dataset
mod6a <- lavaan::sem( lavmodel , data = imp1[[1]] )
summary(mod6a)
# analysis based on all datasets using with
mod6b <- lapply( imp1 , FUN = function(data){
           res <- lavaan::sem( lavmodel , data = data ) 
           return(res)
                } )
# extract parameters and covariance matrices
qhat0 <- lapply( mod6b , FUN = function(ll){  coef(ll) } )
u0 <- lapply( mod6b , FUN = function(ll){  vcov(ll) } )
res6b <- mitools::MIcombine( results = qhat0 , variances = u0 )

# extract informations for all parameters
qhat <- lapply( mod6b , FUN = function(ll){
        h1 <- lavaan::parameterEstimates(ll)
        parnames <- paste0( h1$lhs , h1$op , h1$rhs )
        v1 <- h1$est
        names(v1) <- parnames
        return(v1)    
     } )
se <- lapply( mod6b , FUN = function(ll){
        h1 <- lavaan::parameterEstimates(ll)
        parnames <- paste0( h1$lhs , h1$op , h1$rhs )
        v1 <- h1$se
        names(v1) <- parnames
        return(v1)    
     } ) 
res6c <- pool_mi( qhat = qhat , se = se )     

# function runMI in semTools package
res6d <- semTools::runMI(model=lavmodel , data = imp1 , m = length(imp1) )
  # semTools version 0.4-9 provided an error message
# perform inference with mitml package
se2 <- lapply( se , FUN = function(ss){  ss^2  } )  # input variances
res6e <- mitml::testEstimates(qhat=qhat, uhat=se2)
         
#*** complete model estimation and inference in mitml

# convert into object of class mitml.list
ml02 <- mitml::as.mitml.list( data.ma02)    
# estimate regression
mod7 <- with( ml02 , stats::lm( read ~ hisei + female ) ) 
# inference
res7 <- mitml::testEstimates( mod7 )
            
#*** model comparison
summary(res1)
summary(res2)
summary(res3)
summary(res4)
summary(res5)
summary(res6b)
summary(res6c)
print(res6e)
print(res7)

## End(Not run)

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.