sampler_APT {nimbleAPT}R Documentation

A virtual function to use as a contains argument when writing APT samplers

Description

Modified from NIMBLE's samplers_BASE to include a setTemp method

Details of the adaptive parallel tempering (APT) samplers adapted from nimble's MCMC samplers.

Usage

sampler_APT()

sampler_RW_tempered(model, mvSaved, target, control)

sampler_RW_block_tempered(model, mvSaved, target, control)

sampler_slice_tempered(model, mvSaved, target, control)

sampler_RW_multinomial_tempered(model, mvSaved, target, control)

Arguments

model

(uncompiled) model on which the APT algorithm is to be run

mvSaved

modelValues object to be used to store MCMC samples

target

node(s) on which the sampler will be used

control

named list that controls the precise behavior of the sampler, with elements specific to samplertype. The default values for control list are specified in the setup code of each sampling algorithm. Descriptions of each sampling algorithm, and the possible customizations for each sampler (using the control argument) appear below.

Details

Set up functions for this class should include the following arguments

APT samplers must include "contains = sampler_APT" and include a setTemp method

Value

These functions are called from the addSampler function and return an uncompiled APT sampler object that can be included in an APT sampling scheme.

sampler_APT

base class for APT samplers

When you write a new sampler for use in a NIMBLE MCMC with APT, you must include contains = sampler_APT.

RW sampler

The RW sampler executes adaptive Metropolis-Hastings sampling with a normal proposal distribution (Metropolis, 1953), implementing the adaptation routine given in Shaby and Wells, 2011. This sampler can be applied to any scalar continuous-valued stochastic node, and can optionally sample on a log scale.

The RW sampler accepts the following control list elements:

The RW sampler cannot be used with options log=TRUE and reflective=TRUE, i.e. it cannot do reflective sampling on a log scale.

RW_block sampler

The RW_block sampler performs a simultaneous update of one or more model nodes, using an adaptive Metropolis-Hastings algorithm with a multivariate normal proposal distribution (Roberts and Sahu, 1997), implementing the adaptation routine given in Shaby and Wells, 2011. This sampler may be applied to any set of continuous-valued model nodes, to any single continuous-valued multivariate model node, or to any combination thereof.

The RW_block sampler accepts the following control list elements:

slice sampler

The slice sampler performs slice sampling of the scalar node to which it is applied (Neal, 2003). This sampler can operate on either continuous-valued or discrete-valued scalar nodes. The slice sampler performs a 'stepping out' procedure, in which the slice is iteratively expanded to the left or right by an amount sliceWidth. This sampler is optionally adaptive, governed by a control list element, whereby the value of sliceWidth is adapted towards the observed absolute difference between successive samples.

The slice sampler accepts the following control list elements:

RW_multinomial sampler

This sampler is designed for sampling multinomial target distributions. The sampler performs a series of Metropolis-Hastings steps between pairs of groups. Proposals are generated via a draw from a binomial distribution, whereafter the proposed number density is moved from one group to another group. The acceptance or rejection of these proposals follows a standard Metropolis-Hastings procedure. Probabilities for the random binomial proposals are adapted to a target acceptance rate of 0.5.

The RW_multinomial sampler accepts the following control list elements:

Author(s)

David Pleydell, Daniel Turek

References

Metropolis, N., Rosenbluth, A. W., Rosenbluth, M. N., Teller, A. H., and Teller, E. (1953). Equation of State Calculations by Fast Computing Machines. The Journal of Chemical Physics, 21(6), 1087-1092.

Neal, Radford M. (2003). Slice Sampling. The Annals of Statistics, 31(3), 705-741.

Roberts, G. O. and S. K. Sahu (1997). Updating Schemes, Correlation Structure, Blocking and Parameterization for the Gibbs Sampler. Journal of the Royal Statistical Society: Series B (Statistical Methodology), 59(2), 291-317.

Shaby, B. and M. Wells (2011). Exploring an Adaptive Metropolis Algorithm. 2011-14. Department of Statistics, Duke University.

See Also

configureMCMC addSampler buildMCMC buildAPT runMCMC

Examples

## This example is taken from the nimbleAPT vignette. See the vignette for more details.

bugsCode <- nimbleCode({
   for (ii in 1:nObs) {
       y[ii,1:2] ~ dmnorm(mean=absCentroids[1:2], cholesky=cholCov[1:2,1:2], prec_param=0)
   }
   absCentroids[1:2] <- abs(centroids[1:2])
   for (ii in 1:2) {
       centroids[ii] ~ dnorm(0, sd=1E3)
   }
})

nObs      <- 100
centroids <- rep(-3, 2)
covChol   <- chol(diag(2))

rModel <- nimbleModel(bugsCode,
                     constants=list(nObs=nObs, cholCov=covChol),
                     inits=list(centroids=centroids))

simulate(rModel, "y") ## Use model to simulate data

rModel <- nimbleModel(bugsCode,
                      constants=list(nObs=nObs, cholCov=covChol),
                      data=list(y=rModel$y),
                      inits=list(centroids=centroids))

conf <- configureMCMC(rModel, nodes="centroids", monitors="centroids", enableWAIC = TRUE)

conf$removeSamplers()
conf$addSampler("centroids[1]", type="sampler_RW_tempered", control=list(temperPriors=TRUE))
conf$addSampler("centroids[2]", type="sampler_RW_tempered", control=list(temperPriors=TRUE))
aptR <- buildAPT(conf, Temps=1:5, ULT= 1000, print=TRUE)


[Package nimbleAPT version 1.0.6 Index]