ComradeAdaptMCMC.AdaptMCMC
— TypeAdaptMCMC(;ntemp,
swap=:nonrev,
algorithm = :ram,
fulladapt = true,
acc_sw = 0.234,
all_levels = false
)
Create an AdaptMCMC.jl
sampler. This sampler uses the AdaptiveMCMC.jl
package to sample from the posterior. Namely, this is a parallel tempering algorithm with an adaptive exploration and tempering sampler. For more information please see [https://github.com/mvihola/AdaptiveMCMC.jl].
The arguments of the function are:
ntemp
: Number of temperature to run in parallel temperingswap
: Which temperature swapping strategy to use, options are::norev
(default) uses a non-reversible tempering scheme (still ergodic):single
single randomly picked swap:randperm
swap in random order:sweep
upward or downward sweeps picked at random
algorithm
: exploration MCMC algorithm (default is :ram which uses robust adaptive metropolis-hastings) options are::ram
(default) Robust adaptive metropolis:am
Adaptive metropolis:asm
Adaptive scaling metropolis:aswam
Adaptive scaling within adaptive metropolis
fulladapt
: whether we adapt both the tempering ladder and the exploration kernel (default is true, i.e. adapt everything)acc_sw
: The target acceptance rate for temperature swapsall_levels
: Store all tempering levels to memory (warning this can use a lot of memory)
StatsBase.sample
— Functionsample(post::Posterior, sampler::AdaptMCMC, nsamples, burnin=nsamples÷2, args...; initial_params=nothing, kwargs...)
Sample the posterior post
using the AdaptMCMC
sampler. This will produce nsamples
with the first burnin
steps removed. The initial_params
indicate where to start the sampler from and it is expected to be a NamedTuple
of parameters.
Possible additional kwargs are:
thin::Int = 1
: which says to save only everythin
sample to memoryrng
: Specify a random number generator (default uses GLOBAL_RNG)
This return a tuple where:
- First element are the chains from the sampler. If
all_levels=false
the only the unit temperature (posterior) chain is returned - Second element is the additional ancilliary information about the samples including the loglikelihood
logl
, sampler statestate
, average exploration kernel acceptance rateaccexp
for each tempering level, and average temperate swap acceptance ratesaccswp
for each tempering level.