modelValues are NIMBLE containers built to store values
from models. They can either be built directly from a model
or be custom built via the modelValuesSpec
function.
They consist of rows, where each row can be thought of as a
set of values from a model. Like most nimble objects, and
unlike most R objects, they are passed by reference instead
of by value.
See user manual for more details.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | mvSpec <- modelValuesSpec(vars = c('a', 'b'),
types = c('double', 'double'),
sizes = list(a = 1, b = c(2,2) ) )
mv <- modelValues(mvSpec)
as.matrix(mv)
resize(mv, 2)
as.matrix(mv)
mv['a',1] <- 1
mv['a',2] <- 2
mv['b',1] <- matrix(0, nrow = 2, ncol = 2)
mv['b',2] <- matrix(1, nrow = 2, ncol = 2)
mv['a',]
as.matrix(mv)
basicModelCode <- nimbleCode({
a ~ dnorm(0,1)
for(i in 1:4)
b[i] ~ dnorm(0,1)
})
basicModel <- nimbleModel(basicModelCode)
basicMV <- modelValues(basicModel, m = 2) # m sets the number of rows
basicMV['b',]
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.