I’m wondering if it’s possible to subdivide 3 chains in JAGS on 5 or 6 cores, for example. Here is my code:
library(parallel)
# There is no progression bar using parallel
jags.parallel(data = d$data,
inits = d$inits,
parameters.to.save = d$params,
model.file = model.jags,
n.chains = 3,
n.thin = 10,
n.iter = 9000,
n.burnin = 3000,
working.directory = NULL,
n.cluster = 3) ## the number of cluster it’s taking
As you can see, and this is the default, the number of chains (nc
here which is 3 in my case) equals the number of core used.
- How is this influencing the way the MCMC is sampled?
- Is there an optimal number of core to use with R when running MCMC chains in parallel?
- I saw that I cannot go under 3 cores if I have 3 chains. It gives me this error:
Error in res[[ch]] : subscript out of bounds
. Why? - If I increase the number of cores, it takes longer (as a comparison, with 12 cores it takes 7.2 more time than 3 cores)! Shouldn’t it be the reverse?
- How can I make the script faster without removing iterations, burn-in or adding thinning (more cores?, change the RAM?)?
My computer has 16 cores, so I have flexibility on the number of cores (also have 64 GB of RAM and 3 GHz Intel Xeon E5 processor).