DEMC.jl

Differential Evolution Markov Chain Monte Carlo Code written in julia.
Author chrished
Popularity
5 Stars
Updated Last
5 Months Ago
Started In
January 2018

DEMC - Differential Evolution Markov Chain Monte Carlo

Dev Build Status Codecov Coveralls

  • implementation of the "DEMCz" algorithm proposed in Ter Braak and Vrugt (2008)

Use Cases

  • useful for simulating distributions that are not easily differentiable, have moderate dimensionality (>1, <5?), and dimensions are potentially highly correlated. One example is to simulate parameter distributions in indirect inference estimators.

  • moderate dimensionality is somewhat unclear, tests work alright with 10-20 dimensions, but behavior deteriorates. See https://mc-stan.org/users/documentation/case-studies/curse-dims.html

Sample Usage

using Distributions
using DEMC

μ = zeros(5)
A = rand(5,5)
Σ = A'*A
distr = MvNormal(μ, Σ)
logobj(mean) = logpdf(distr, mean)
Zinit = rand(distr, 100)'
# sample from distr using standard options
opts = DEMC.demcopt(ndim)
mc, Z = DEMC.demcz_sample(logobj, Zinit, opts)
# see tests for further examples (also annealing and parallel)

# options you can set
# fieldnames(typeof(opts))
# :N - number of chains
# :K - add current draw to Z every K steps
# :Ngeneration - total number of steps
# :Nblocks - number of blocks
# :blockindex - subset of parameters in each block
# :eps_scale - scale of random draw around DE step
# :γ - scale of DE step (2.38 for normal distribution)
# :verbose - print avg value and avg parameters of chain  
# :print_step - print every ... steps
# :T0 - initial temperature (only for annealing)
# :TN - final temperature (only for annealing)
# :autostop - :Rhat is only possibility so far (stop when Gelman-Rubin Rhat falls below a threshold)
# :autostop_every - checks autostop criterion every autostop_every generations (only for serial computation, in parallel mode checks when chains sync
# :autostop_Rhat - maximum Rhat to trigger autostop (should be close to 1, e.g. below 1.1)

References

Gelman, A., Carlin, J. B., Stern, H. S., Dunson, D. B., Vehtari, A., & Rubin, D. B. (2014). Bayesian data analysis (Vol. 2). Boca Raton, FL: CRC press.

Ter Braak, Cajo JF (2006). A Markov Chain Monte Carlo version of the genetic algorithm Differential Evolution: easy Bayesian computing for real parameter spaces. Statistics and Computing, 16(3), 239-249.

ter Braak, Cajo JF, and Jasper A. Vrugt. "Differential evolution Markov chain with snooker updater and fewer chains." Statistics and Computing 18.4 (2008): 435-446.