Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

simNodes

Basic nimbleFunctions for calculate, simulate, and getLogProb with a set of nodes


Description

simulate, calculate, or get existing log probabilities for the current values in a NIMBLE model

Usage

simNodes(model, nodes)

calcNodes(model, nodes)

getLogProbNodes(model, nodes)

Arguments

model

A NIMBLE model

nodes

A set of nodes. If none are provided, default is all model$getNodeNames()

Details

These are basic nimbleFunctions that take a model and set of nodes and return a function that will call calculate, simulate, or getLogProb on those nodes. Each is equivalent to a direct call from R, but in nimbleFunction form they can be be compiled and can be put into a nimbleFunctionList. For example, myCalc <- calcNodes(model, nodes); ans <- myCalc() is equivalent to ans <- model$calculate(nodes), but one can also do CmyCalc <- compileNimble(myCalc) to get a faster version.

In nimbleFunctions, for only one set of nodes, it is equivalent or slightly better to simply use model$calculate(nodes) in the run-time code. The compiler will process the model-nodes combination in the same way as would occur by creating a specialized calcNodes in the setup code. However, if there are multiple sets of nodes, one can do the following:

Setup code: myCalcs <- nimbleFunctionList(calcNodes); myCalcs[[1]] <- calcNodes(model, nodes[[1]]); myCalcs[[2]] <- calcNodes[[2]]

Run code: for(i in seq_along(myCalcs)) {ans[i] <- myCalcs[[i]]()}

Author(s)

Perry de Valpine


nimble

MCMC, Particle Filtering, and Programmable Hierarchical Modeling

v0.11.0
BSD_3_clause + file LICENSE | GPL (>= 2)
Authors
Perry de Valpine [aut], Christopher Paciorek [aut, cre], Daniel Turek [aut], Nick Michaud [aut], Cliff Anderson-Bergman [aut], Fritz Obermeyer [aut], Claudia Wehrhahn Cortes [aut] (Bayesian nonparametrics system), Abel Rodrìguez [aut] (Bayesian nonparametrics system), Duncan Temple Lang [aut] (packaging configuration), Sally Paganin [aut] (reversible jump MCMC), Jagadish Babu [ctb] (code for the compilation system for an early version of NIMBLE), Lauren Ponisio [ctb] (contributions to the cross-validation code), Peter Sujan [ctb] (multivariate t distribution code)
Initial release
2021-04-16

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.