## 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)
Run the code above in your browser using DataLab