sampler_mchmc | R Documentation |
Metropolis-Coupled version of HMC, i.e. running multiple chains at different temperatures which stochastically swap positions.
sampler_mchmc(
start,
distr_name = NULL,
distr_params = NULL,
epsilon = 0.5,
L = 10,
nChains = 6,
delta_T = 4,
swap_all = TRUE,
iterations = 1024L,
weights = NULL,
custom_density = NULL
)
start |
Vector. Starting position of the sampler. |
distr_name |
Name of the distribution from which to sample from. |
distr_params |
Distribution parameters. |
epsilon |
Size of the leapfrog step |
L |
Number of leapfrog steps per iteration |
nChains |
Number of chains to run. |
delta_T |
numeric, >1. Temperature increment parameter. The bigger this number, the steeper the increase in temperature between the cold chain and the next chain |
swap_all |
Boolean. If true, every iteration attempts floor(nChains / 2) swaps. If false, only one swap per iteration. |
iterations |
Number of iterations of the sampler. |
weights |
If using a mixture distribution, the weights given to each constituent distribution. If none given, it defaults to equal weights for all distributions. |
custom_density |
Instead of providing names, params and weights, the user may prefer to provide a custom density function. |
Metropolis-Coupled HMC does not support discrete distributions.
This algorithm has been used to model human data in \insertCitecastillo2024ExplainingFlawsHuman;textualsamplr.
A named list containing
Samples: the history of visited places (an n x d x c array, n = iterations; d = dimensions; c = chain index, with c==1 being the 'cold chain')
Momentums: the history of momentum values (an n x d x c array, n = iterations; d = dimensions; c = chain index, with c==1 being the 'cold chain'). Nothing is proposed in the first iteration (the first iteration is the start value) and so the first row is NA
Acceptance Ratio: The proportion of proposals that were accepted (for each chain).
Beta Values: The set of temperatures used in each chain
Swap History: the history of chain swaps
Swap Acceptance Ratio: The ratio of swap acceptances
result <- sampler_mchmc(
distr_name = "norm", distr_params = c(0,1),
start = 1, epsilon = .01, L = 100
)
cold_chain <- result$Samples[,,1]
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.