The bottom of the answer in this question (Calculating CIs of fixed effects using confint in R) suggests one should see user
time > elapsed
time when parallel works. Despite specifying parallel = "multicore", ncpus = 4
when running boot.ci
I don't see that result. Also, I only see about 30% CPU load in Mac's Activity Monitor as it runs. Does this mean I'm not parallel processing with my 4-core iMac? If not, any advice on getting it to work?
Here's an example:
library(car)
library(boot)
set.seed(47)
y <- rgamma(2000, 2)
x1 <- 3 * y + rnorm(2000)
x2 <- y^2 + rnorm(2000)
x3 <- rnorm(2000)
MyData <- data.frame(c(y, x1, x2, x3))
MyModel <- lm(y ~ x1 + x2 + x3, data = MyData)
# Boot doesn't have a parallel option that I know of
system.time(BootModel <- Boot(MyModel, R = 3000))
#-----------------------
user system elapsed
10.164 1.086 11.263
#-----------------------
# calculate CIs for a single coefficient
# boot.ci has a parallel option, but the sys.time results are the same
system.time(ConfBoot <- boot.ci(BootModel, level = c(.90, .95, .99), type = "bca",
index = 2, parallel = "multicore", ncpus = 4))
#-----------------------
user system elapsed
19.698 0.367 20.162
On a related note, why does boot.ci take so long to compute the BCa confidence intervals? My reading of the code is that bca.ci
takes the existing replicates from boot.out
for its calculations, so it doesn't seem like it should take so much longer to run than boot
does (via Boot
in this example).