MCMC Algorithms

MCMC Suite Example - An example of using NIMBLE’s MCMC Suite to run BUGS, JAGS, or different NIMBLE MCMCs.

Avoid Recompiling an MCMC - How to avoid re-compiling an MCMC algorithm,when using different MCMC sampling combinations for the same model.

Restarting NIMBLE MCMC - How to continue an MCMC algorithm from where it left off, after restarting an R session.

Gaussian Process and NNGP Models with MCMC - How to fit Gaussian Process (GP) and Nearest Neighbor Gaussian Process (NNGP) models with NIMBLE’s MCMC.

Saving Model and MCMC State - How to save the state of a model object and associated MCMC algorithm, allowing you to restart R, reload the state into a new model and MCMC, and resume the MCMC sampling where it left off.

Parallel MCMC Chains - How to execute parallel MCMC chains using the parallel package, and also to optionally continue running each MCMC chain after assessing convergence.

Record (Unnormalized) Model Log Density - How to record the sum of the (unnormalized) model posterior log-density values on every MCMC iteration.

 

MCMC Samplers

Recording Sampler Pre- and Post-Update Values - How to modify NIMBLE MCMC samplers, so they internally record parameter values before and after updating them. This can be useful for post-analysis of sampler performance.

Timing Individual MCMC Samplers - An example of how to measure the runtime of each individual MCMC sampler. This can be useful for post-analysis of sampler performance.

Adding a Conjugate Sampler - How to manually add a conjugate sampler to an MCMC configuration object.

Recording Sampler Tuning Parameters - Writing the RW sampler so that it records (and you can access) the scale history and acceptance rate history.

Sampler State Variables - How to extract and set the “state” variables, stored internally in MCMC sampling algorithms.

Toggling MCMC Samplers On/Off - How to modify MCMC samplers so they can be toggled on or off for different MCMC runs or datasets.

Accessing RW Sampler Scale and Acceptance Rate History - How to access the full history of proposal scale, proposal covariance, and acceptance rate of RW and RW_block samplers.

 

Other

MCMC Style Guide - The NIMBLE MCMC Team welcomes external contributions of sampling algorithms, new features, or otherwise. Please see this guide regarding MCMC code formatting.

Code Substitution - How to manipulate code objects in R, including use of the substitute and eval functions.

JAGS Block Sampling Adaptation - Describes the algorithm underlying JAGS’ block sampler adaptation scheme.

Sparse Matrix Calls - Demonstrating how to use sparse matrix operations from the Matrix package inside compiled NIMBLE functions and models.