pmcmc_chains_prepare | R Documentation |
Run a pMCMC, with sensible random number behaviour, but schedule execution of the chains yourself. Use this if you want to distribute chains over (say) the nodes of an HPC system.
pmcmc_chains_prepare(path, pars, filter, control, initial = NULL)
pmcmc_chains_run(chain_id, path, n_threads = NULL)
pmcmc_chains_collect(path)
pmcmc_chains_cleanup(path)
path |
The path to use to exchange inputs and results. You
can use a temporary directory or a different path (relative or
absolute). Several rds files will be created. It is strongly
recommended not to use |
pars |
A |
filter |
A |
control |
A pmcmc_control object which will control how the MCMC runs, including the number of steps etc. |
initial |
Optional initial starting point. If given, it must
be compatible with the parameters given in |
chain_id |
The integer identifier of the chain to run |
n_threads |
Optional thread count, overriding the number set
in the |
Basic usage will look like
path <- mcstate::pmcmc_chains_prepare(tempfile(), pars, filter, control) for (i in seq_len(control$n_chains)) { mcstate::pmcmc_chains_run(i, path) } samples <- mcstate::pmcmc_chains_collect(path) mcstate::pmcmc_chains_cleanup(path)
You can safely parallelise (or not) however you like at the point where the loop is (even across other machines) and get the same outputs regardless.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.