configureMCMC {nimble}R Documentation

Build the MCMCconf object for construction of an MCMC object

Description

Creates a default MCMC configuration for a given model.

Usage

configureMCMC(
  model,
  nodes,
  control = list(),
  monitors,
  thin = 1,
  monitors2 = character(),
  thin2 = 1,
  useConjugacy = getNimbleOption("MCMCuseConjugacy"),
  onlyRW = FALSE,
  onlySlice = FALSE,
  multivariateNodesAsScalars = getNimbleOption("MCMCmultivariateNodesAsScalars"),
  enableWAIC = getNimbleOption("MCMCenableWAIC"),
  controlWAIC = list(),
  print = getNimbleOption("verbose"),
  autoBlock = FALSE,
  oldConf,
  ...
)

Arguments

model

A NIMBLE model object, created from nimbleModel

nodes

An optional character vector, specifying the nodes and/or variables for which samplers should be created. Nodes may be specified in their indexed form, y[1, 3]. Alternatively, nodes specified without indexing will be expanded fully, e.g., x will be expanded to x[1], x[2], etc. If missing, the default value is all non-data stochastic nodes. If NULL, then no samplers are added.

control

An optional list of control arguments to sampler functions. If a control list is provided, the elements will be provided to all sampler functions which utilize the named elements given. For example, the standard Metropolis-Hastings random walk sampler (sampler_RW) utilizes control list elements adaptive, adaptInterval, and scale. (Internally it also uses targetNode, but this should not generally be provided as a control list element). The default values for control list arguments for samplers (if not otherwise provided as an argument to configureMCMC() ) are in the setup code of the sampling algorithms.

monitors

A character vector of node names or variable names, to record during MCMC sampling. This set of monitors will be recorded with thinning interval thin, and the samples will be stored into the mvSamples object. The default value is all top-level stochastic nodes of the model – those having no stochastic parent nodes.

thin

The thinning interval for monitors. Default value is one.

monitors2

A character vector of node names or variable names, to record during MCMC sampling. This set of monitors will be recorded with thinning interval thin2, and the samples will be stored into the mvSamples2 object. The default value is an empty character vector, i.e. no values will be recorded.

thin2

The thinning interval for monitors2. Default value is one.

useConjugacy

A logical argument, with default value TRUE. If specified as FALSE, then no conjugate samplers will be used, even when a node is determined to be in a conjugate relationship.

onlyRW

A logical argument, with default value FALSE. If specified as TRUE, then Metropolis-Hastings random walk samplers (sampler_RW) will be assigned for all non-terminal continuous-valued nodes nodes. Discrete-valued nodes are assigned a slice sampler (sampler_slice), and terminal nodes are assigned a posterior_predictive sampler (sampler_posterior_predictive).

onlySlice

A logical argument, with default value FALSE. If specified as TRUE, then a slice sampler is assigned for all non-terminal nodes. Terminal nodes are still assigned a posterior_predictive sampler.

multivariateNodesAsScalars

A logical argument, with default value FALSE. If specified as TRUE, then non-terminal multivariate stochastic nodes will have scalar samplers assigned to each of the scalar components of the multivariate node. The default value of FALSE results in a single block sampler assigned to the entire multivariate node. Note, multivariate nodes appearing in conjugate relationships will be assigned the corresponding conjugate sampler (provided useConjugacy == TRUE), regardless of the value of this argument.

enableWAIC

A logical argument, specifying whether to enable WAIC calculations for the resulting MCMC algorithm. Defaults to the value of nimbleOptions('MCMCenableWAIC'), which in turn defaults to FALSE. Setting nimbleOptions('enableWAIC' = TRUE) will ensure that WAIC is enabled for all calls to configureMCMC and buildMCMC.

controlWAIC

A named list of inputs that control the behavior of the WAIC calculation. See help(waic).

print

A logical argument, specifying whether to print the ordered list of default samplers.

autoBlock

A logical argument specifying whether to use an automated blocking procedure to determine blocks of model nodes for joint sampling. If TRUE, an MCMC configuration object will be created and returned corresponding to the results of the automated parameter blocking. Default value is FALSE.

oldConf

An optional MCMCconf object to modify rather than creating a new MCMCconf from scratch

...

Additional named control list elements for default samplers, or additional arguments to be passed to the autoBlock function when autoBlock = TRUE

Details

See MCMCconf for details on how to manipulate the MCMCconf object

Author(s)

Daniel Turek

See Also

buildMCMC runMCMC nimbleMCMC


[Package nimble version 1.2.1 Index]