Conversion from BBPMM output to mice's mids object or prepares imputed data for coda's mcmc or mcmc.list objects

Share:

Description

‘impdiagnosticconversion’ prepares the output of BBPMM for coda's (Plummer et al. 2006) mcmc or mcmc.list object. It is also possible to convert the output into an object of the type mids provided by the package mice (van Buuren, Groothuis-Oudshoorn 2011).

Usage

1
impdiagnosticconversion(imputed.data, type=c("mcmc.list","mcmc","mids"))

Arguments

imputed.data

An object of the type ‘imp’ returned by BaBooN's BBPMM imputation method.

type

A string choosing the type of output: Either "mcmc.list", "mcmc" or "mids". Default="mcmc.list".

Details

To provide a wider variety of analysis and diagnostic tools and facilitate the collaboration between different imputation packages, we started to create a conversion tool. At the moment it is possible to transform an output created by BaBooN's BBPMM function into a mids-like object returned from mice (van Buuren, Groothuis-Oudshoorn 2011). For diagnostics with the help of the functions provided by the package coda (Plummer et al. 2006), this function prepares the output. It returns a list, that isn't directly of the desired class, but results in a list with four elements, containing the chains for the means, variances, medians and standard deviations of the imputed values transformed to the specified type respectively. Hence, accessing the first element of the list returns actual the converted means, the second element contains the converted variances and so on.

We hope it is somehow an impulse for future standardisation or interchangeability of outputs generated by different multiple imputation routines and analysing the imputed values.

Value

See for details mcmc, mcmc.list or mids. Remark: Converting to mcmc or mcmc.list results in a list with four elements (medians, vars, medians, sds), containing the chains for the means, variances, medians and standard deviations of the imputed values transformed to the specified type. See the examples.

Author(s)

Thorsten Schnapp, Florian Meinfelder [ctb]

References

Cowles, M.K. and Carlin, B.P. (1996) Markov Chain Monte Carlo Convergence Diagnostics: A Comparative Review. Journal of the American Statistical Association, Vol. 91, pp. 883–904.

Koller-Meinfelder, F. (2009) Analysis of Incomplete Survey Data – Multiple Imputation Via Bayesian Bootstrap Predictive Mean Matching, doctoral thesis.

Plummer, M. and Best, N. and Cowles, K. and Vines, K. (2006) CODA: Convergence Diagnosis and Output Analysis for MCMC, R News, Vol. 6, pp. 7–11

Van Buuren, S. and Groothuis-Oudshoorn, K. (2011) mice: Multivariate Imputation by Chained Equations in R. Journal of Statistical Software, Vol. 45, No. 3, pp. 1–67. URL http://www.jstatsoft.org/v45/i03/.

Van Buuren, S. (2012) Flexible imputation of missing data. Boca Raton: CRC Press.

Sarkar, Deepayan (2008) Lattice: Multivariate Data Visualization with R. New York: Springer.

See Also

mcmc, mcmc.list, mids, mids-class, mice, plot.mids, BBPMM

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
## Not run: 
### sample data set with non-normal variables
set.seed(1000)
n <- 50
x1 <- round(runif(n,0.5,3.5))
x2 <- as.factor(c(rep(1,10),rep(2,25),rep(3,15)))
x3 <- round(rnorm(n,0,3))
y1 <- round(x1-0.25*(x2==2)+0.5*x3+rnorm(n,0,1))
y1 <- ifelse(y1<1,1,y1)
y1 <- as.factor(ifelse(y1>4,5,y1))
y2 <- x1+rnorm(n,0,0.5)
y3 <- round(x3+rnorm(n,0,2))
data1 <- as.data.frame(cbind(x1,x2,x3,y1,y2,y3))
misrow1 <- sample(n,20)
misrow2 <- sample(n,15)
misrow3 <- sample(n,10)
is.na(data1[misrow1, 4]) <- TRUE
is.na(data1[misrow2, 5]) <- TRUE
is.na(data1[misrow2, 6]) <- TRUE

### imputation
imputed.data <- BBPMM(data1, nIter=3, M=3)

### Test Conversion
if(!require(coda)) install.packages("coda")
if(!require(mice)) install.packages("mice")

require(coda) ## see references
require(mice) ## see references
require(lattice) ## see references

## conversion to mcmc
imp.to.mcmc <- impdiagnosticconversion(imputed.data,
                                       type="mcmc")

## conversion to mcmc.list
imp.to.mcmc.list <- impdiagnosticconversion(imputed.data,
                                            type="mcmc.list")

## conversion to mids
imp.to.mids <- impdiagnosticconversion(imputed.data,
                                       type="mids")

### Test

## mcmc:
plot(imp.to.mcmc$means[[1]])
acfplot(imp.to.mcmc$vars[[1]])
plot(imp.to.mcmc$medians[[1]])
acfplot(imp.to.mcmc$sds[[1]])

## mcmc.list:
xyplot(imp.to.mcmc.list[[1]]) ## Mean
qqmath(imp.to.mcmc.list[[2]]) ## Variance
xyplot(imp.to.mcmc.list[[3]]) ## Median
qqmath(imp.to.mcmc.list[[4]]) ## Std.dev.

## mids:
# Chain-plot from mice
mice:::plot.mids(imp.to.mids)


## End(Not run)