An R package for generating multiple imputations using a Gaussian copula This package generates multiple imputations using Peter Hoff's sbgcop package. The package can also convert the output to allow for seamless integration with the mice package, which can be used to analyze the multiple imputed data sets.
```r
library(devtools) devtools::install_github("bojinov/gcImp") Here is an exmaple:
N <- 200 rho <- matrix(0.3, 2, 2) diag(rho) <- 1
rho.chol <- chol(rho) samples.mvn <- matrix(rnorm(N * 2), ncol = 2) %*% rho.chol
p <- rep(0.2, N) # MCAR
R <- sapply(1:N, function(jj) sample(c(NA, 1), size = 1, prob = c(p[jj], 1 - p[jj])))
samples.mvn[, 2] <- samples.mvn[, 2] * R out <- gcImp(samples.mvn) print(out)
plot(out$sbgcop.out$C.psamp[1,2,], type = "l")
plot(colMeans(out$sbgcop.out$Y.imput[,2,]), type = "l")
library(mcmcplots) mcmcplots::mcmcplot(colMeans(out$sbgcop.out$Y.imput[,2,])) mcmcplots::mcmcplot(out$sbgcop.out$C.psamp[1,2,])
imp <- gc.as.mids(out)
stacked <- mice::complete(imp, "long") fit <- lm(V1 ~ V2, data = stacked) coef(fit)
fit <- with(imp, lm(V1 ~ V2)) est <- mice::pool(fit) summary(est)
mice::densityplot(imp)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.