Created
September 22, 2011 21:20
-
-
Save jrnold/1236095 to your computer and use it in GitHub Desktop.
Run Amelia in parallel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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