View source: R/BUGS_readBUGS.R
nimbleModel | R Documentation |
Processes BUGS model code and optional constants, data, and initial values. Returns a NIMBLE model (see modelBaseClass
) or model definition.
nimbleModel(
code,
constants = list(),
data = list(),
inits = list(),
dimensions = list(),
returnDef = FALSE,
where = globalenv(),
debug = FALSE,
check = getNimbleOption("checkModel"),
calculate = TRUE,
name = NULL,
buildDerivs = getNimbleOption("buildModelDerivs"),
userEnv = parent.frame()
)
code |
code for the model in the form returned by |
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 |
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. Values that are NA will not be flagged as data. |
inits |
named list of starting values for model variables. Unlike JAGS, should only be a single list, not a list of lists. |
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). |
where |
argument passed to |
debug |
logical indicating whether to put the user in a browser for debugging. Intended for developer use. |
check |
logical indicating whether to check the model object for missing or invalid values. Default is given by the NIMBLE option 'checkModel'. See |
calculate |
logical indicating whether to run |
name |
optional character vector giving a name of the model for internal use. If omitted, a name will be provided. |
buildDerivs |
logical indicating whether to build derivative capabilities for the model. |
userEnv |
environment in which if-then-else statements in BUGS code will be evaluated if needed information not found in |
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).
NIMBLE development team
readBUGSmodel
for creating models from BUGS-format model files
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.