rjags (version 4-10)

adapt: Adaptive phase for JAGS models

Description

Update the model in adaptive mode.

Usage

adapt(object, n.iter, end.adaptation=FALSE, …)

Arguments

object

a jags model object

n.iter

length of the adaptive phase

end.adaptation

logical flag. If TRUE then adaptive mode will be turned off on exit.

additional arguments to the update method

Value

Returns TRUE if all the samplers in the model have successfully adapted their behaviour to optimum performance and FALSE otherwise.

Details

This function is not normally called by the user. It is called by the jags.model function when the model object is created.

When a JAGS model is compiled, it may require an initial sampling phase during which the samplers adapt their behaviour to maximize their efficiency (e.g. a Metropolis-Hastings random walk algorithm may change its step size). The sequence of samples generated during this adaptive phase is not a Markov chain, and therefore may not be used for posterior inference on the model.

The adapt function updates the model for n.iter iterations in adaptive mode. Then each sampler reports whether it has acheived optimal performance (e.g. whether the rejection rate of a Metropolis-Hasting sampler is close to the theoretical optimum). If any sampler reports failure of this test then adapt returns FALSE.

If end.adaptation = TRUE, then adaptive mode is turned off on exit, and further calls to adapt() do nothing. The model may be maintained in adaptive mode with the default option end.adaptation = FALSE so that successive calls to adapt() may be made until adaptation is satisfactory.