nimbleModel: Create a NIMBLE BUGS model

Description Usage Arguments Details Author(s) Examples

Description

processes BUGS model code and optional constants, data, and initial values. Returns a NIMBLE model or model definition

Usage

1
2
3
nimbleModel(code, name, constants = list(), dimensions = list(),
  data = list(), inits = list(), returnDef = FALSE, where = globalenv(),
  debug = FALSE)

Arguments

code

code for the model in the form returned by nimbleCode or (equivalently) quote

name

optional character vector giving a name of the model for internal use. If omitted, a name will be provided.

constants

named list of constants in the model. Constants cannot be subsequently modified. For compatibility with JAGS and BUGS, one can include data values with constants and nimbleModel will automatically distinguish them based on what appears on the left-hand side of expressions in code.

dimensions

named list of dimensions for variables. Only needed for variables used with empty indices in model code that are not provided in constants or data.

returnDef

logical indicating whether the model should be returned (FALSE) or just the model definition (TRUE).

debug

logical indicating whether to put the user in a browser for debugging. Intended for developer use.

where

argument passed to setRefClass, indicating the environment in which the reference class definitions generated for the model and its modelValues should be created. This is needed for managing package namespace issues during package loading and does not normally need to be provided by a user.

data

named list of values for the data nodes. Data values can be subsequently modified. Providing this argument also flags nodes as having data for purposes of algorithms that inspect model structure.

Details

See the User Manual or help(modelBaseClass) for information about manipulating NIMBLE models created by nimbleModel, including methods that operate on models, such as getDependencies.

The user may need to provide dimensions for certain variables as in some cases NIMBLE cannot automatically determine the dimensions and sizes of variables. See the User Manual for more information.

As noted above, one may lump together constants and data (as part of the constants argument (unlike R interfaces to JAGS and BUGS where they are provided as the data argument). One may not provide lumped constants and data as the data argument.

For variables that are a mixture of data nodes and non-data nodes, any values passed in via inits for components of the variable that are data will be ignored. All data values should be passed in through data (or constants as just discussed).

Author(s)

NIMBLE development team

Examples

1
2
3
4
5
6
7
code <- nimbleCode({
    x ~ dnorm(mu, sd = 1)
    mu ~ dnorm(0, sd = prior_sd)
})
constants = list(prior_sd = 1)
data = list(x = 4)
Rmodel <- nimbleModel(code, constants = constants, data = data)

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