Skip to content

Instantly share code, notes, and snippets.

@jrnold
Created September 22, 2011 21:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jrnold/1236095 to your computer and use it in GitHub Desktop.
Save jrnold/1236095 to your computer and use it in GitHub Desktop.
Run Amelia in parallel
library("Amelia")
library("foreach")
## or backend of choice
library("doMC")
registerDoMC()
ameliapar <- function(x, m=5, p2s=0, ...) {
impdata <- foreach (i = 1:m,
.combine = "c",
.packages="Amelia") %dopar% {
amelia(x, m=1, p2s=p2s, ...)
}
if (all(sapply(impdata, class) == "amelia")) {
impdata <- do.call(ameliabind, impdata)
}
impdata
}
data(africa)
a.out <- amelia(m = 10, x = africa, cs = "country",
ts = "year", logs = "gdp_pc", .parallel=TRUE, p2s=0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment