Download NIMBLE User Manual
Transcript
CHAPTER 6. USING NIMBLE MODELS FROM R
61
pump$isData(c('x[1]', 'x[2]', 'alpha'))
## [1]
TRUE
TRUE FALSE
You can also query variables to determine if the nodes that are part of a variable are
data nodes.
pump$isData('x')
##
[1] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
pump$isData('x[1:3]')
## [1] TRUE TRUE TRUE
6.6
The modelValues data structure
modelValues are containers designed for storing values for models. They may be used for
model outputs or model inputs. A modelValues object will contain rows of variables. Each
row contains one object of each variable, which may be multivariate. The simplest way to
build a modelValues object is from a model object. This will create a modelValues object
with the same variables as the model. Although they were motivated by models, one is free
to set up a modelValues with any variables one wants.
pumpModelValues = modelValues(pumpModel, m = 2)
pumpModel$x
##
[1]
5
1
5 14
3 19
1
1
4 22
pumpModelValues$x
## [[1]]
## [1] NA NA NA NA NA NA NA NA NA NA
##
## [[2]]
## [1] NA NA NA NA NA NA NA NA NA NA
In this example, pumpModelValues has the same variables as pumpModel, and we set
pumpModelValues to have m = 2 rows. As you can see, the rows are stored as elements of a
list.
Alternatively, one can define a modelValues object manually via the modelValuesSpec
function, like this: