Run a slice-only baseline MCMC configuration in parallel
Source:R/runners.R
run_only_slice_parallel.RdRuns multiple independent MCMC chains using a strict slice-only sampling
strategy (onlySlice semantics), in parallel, on either a PSOCK or FORK
backend. All stochastic nodes are updated exclusively with slice samplers,
with no use of random-walk, block, conjugate, or gradient-based samplers.
Arguments
- build_fn
Function building per-chain model objects (see Builder contract).
- niter
Integer; total number of MCMC iterations.
- nburnin
Integer; number of burn-in iterations.
- thin
Integer; thinning interval.
- monitors
Optional character vector of monitored nodes.
- nchains
Integer; number of chains to run.
- seed
Integer; base seed (chain
kusesseed + k - 1).- n_cores
Integer; number of parallel workers (default =
nchains).- extra_export
Optional character vector of additional objects to export to workers.
- parallel_backend
Character; parallel backend to use (
"PSOCK","FORK", or"AUTO").- worker_log
Logical; whether to emit minimal per-worker diagnostic logs.
- useConjugacy
Logical; passed for API consistency but ignored (slice-only).
Value
A list with components:
samples: posterior samples (combined across chains when possible)runtime_s: wall-clock runtime (seconds) for the parallelrunMCMC()phaseconf:NULLin parallel mode; per-chain configurations are attached as attributeconf_by_chain
Details
This function is primarily intended as a robust convergence-oriented baseline for complex or non-differentiable models (e.g. models involving truncated distributions, constrained parameters, or piecewise likelihoods), for which default sampler configurations or HMC/NUTS are inappropriate.
Implementation notes:
Each worker builds and configures its own model and MCMC independently.
All existing samplers are removed and replaced by slice samplers on all stochastic nodes.
Parallel execution can rely on a PSOCK cluster (portable) or a FORK backend (Unix-alike systems only).
The reported runtime measures the wall-clock time spent in
runMCMC(), excluding model construction and compilation.
Builder contract:
build_fn()must work either asbuild_fn()orbuild_fn(chain_id = <int>, export_global = <logical>).It must return a list containing at least:
model: an uncompilednimbleModelcmodel: the compiled model (compileNimble(model))conf: an MCMC configuration object