configureMCMC: Turn BUGS model code into an object for use in 'nimbleModel'...

Description Usage Arguments Details Author(s) Examples

Description

Simply keeps model code as an R call object, the form needed by nimbleModel and optionally usable by readBUGSmodel

Usage

1
2
3
4
configureMCMC(model, oldSpec, nodes, control = list(), monitors, thin = 1,
  monitors2 = character(), thin2 = 1, useConjugacy = TRUE,
  onlyRW = FALSE, onlySlice = FALSE, multivariateNodesAsScalars = FALSE,
  print = FALSE)

Arguments

code

expression providing the code for the model

model

A NIMBLE model object, created from nimbleModel(...)

nodes

An optional character vector, specifying the nodes for which samplers should be created. Nodes may be specified in their indexed form, \'y[1, 3]\', or 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\', \'scale\', and also \'targetNode\' however this should not generally be provided as a control list element to configureMCMC(). The default values for control list arguments for samplers (if not otherwise provided as an argument to configureMCMC() ) are contained in the \'controlDefaultList\' object.

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.

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.

thin

The thinning interval for \'monitors\'. Default value is one.

thin2

The thinning interval for \'monitors2\'. Default value is one.

useConjugacy

A boolean 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 boolean 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 (predictive) nodes are assigned an end sampler (sampler_end).

onlySlice

A boolean argument, with default value FALSE. If specified as TRUE, then a slice sampler is assigned for all non-terminal nodes. Terminal (predictive) nodes are still assigned an end sampler (sampler_end).

multivariateNodesAsScalars:

A boolean 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.

print

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

Details

It is equivalent to use the R function quote. nimbleCode is simply provided as a more readable alternative for NIMBLE users not familiar with quote.

Author(s)

Daniel Turek

Daniel Turek

Examples

1
2
3
4
5
6
7
code <- nimbleCode({
    x ~ dnorm(mu, sd = 1)
    mu ~ dnorm(0, sd = prior_sd)
})
Build the MCMCspec object for construction of an MCMC object

Creates a defaut MCMC specification for a given model.  The resulting object is suitable as an argument to buildMCMC().

thirdwing/nimble documentation built on May 31, 2019, 10:41 a.m.