I'm very new to Bayesian models and MCMC, so please bear with me while I try to explain.
I'm trying to use the R package "conStruct", which provides "A method for modeling genetic data as a combination of discrete layers, within each of which relatedness may decay continuously with geographic distance." The analyses of this package are implemented in rstan
.
I'm aiming to parallelize the following code. However, my main issue is that, from trying to understand posts like this and this, parallelization is difficult when these chains have to be run sequentially. Is this possible? And if so, how would I do so?
Importantly, here are the definitions for n.chains and n.iter (the other arguments aren't as important to understand in this context):
n.chains: An integer indicating the number of MCMC chains to be run in the analysis. n.iter: An integer giving the number of iterations each MCMC chain is run. If the number of iterations is greater than 500, the MCMC is thinned so that the number of retained iterations is 500 (before burn-in).
conStruct(spatial = FALSE,
K = 1,
freqs = allele_frqs,
geoDist = NULL,
coords = coords,
prefix = "nsp_K1_iter5000_chains3",
n.chains = 3,
n.iter = 5000)
Alternatively, could I run each chain at a time, but on different cores? How would I change my code to do that?
Thanks so much!