
Last chance! 50% off unlimited learning
Sale ends in
modelValuesBaseClass
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 modelValuesConf
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.
# NOT RUN {
mvConf <- modelValuesConf(vars = c('a', 'b'),
types = c('double', 'double'),
sizes = list(a = 1, b = c(2,2) ) )
mv <- modelValues(mvConf)
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',]
# }
Run the code above in your browser using DataLab