I was using boot
function in R
to implement bootstrap. My question is how to set boot
to exploit its parallel option. Consider the following concrete example of estimating median.
med_est <- function(dat, indices){
.dat <- dat[indices]
median(.dat)
}
dat <- rnorm(200)
system.time(boot(dat, med_est, R = 10000))
system.time(boot(dat, med_est, R = 10000, parallel = "multicore"))
I don't know how to use the parallel
option in boot
function. Letting parallel = "multicore"
does not boost the speed at time. I have tried more complicated estimation problems. But I did not see the difference. So I guess I did not use boot
correctly. My machine is double-core Mac.
From the boot
manual (bolding is mine).
boot(data, statistic, R, sim = "ordinary", stype = c("i", "f", "w"), strata = rep(1,n), L = NULL, m = 0, weights = NULL, ran.gen = function(d, p) d, mle = NULL, simple = FALSE, ..., parallel = c("no", "multicore", "snow"), ncpus = getOption("boot.ncpus", 1L), cl = NULL)
try:
system.time(boot(dat, med_est, R = 10000, parallel = "multicore", ncpus=2))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With