Description Usage Arguments Details Author(s) Examples
Copies values from a NIMBLE model or modelValues object to
another NIMBLE model or modelValues. Work in R and NIMBLE.
The NIMBLE keyword copy
is identical to
nimCopy
1 2 |
from |
Either a NIMBLE model or modelValues object |
to |
Either a NIMBLE model or modelValues object |
nodes |
The nodes of object |
nodesTo |
The nodes of object |
row |
If |
rowTo |
If |
logProb |
A logical value indicating whether the log
probabilities of the given nodes should also be copied
(i.e. if |
See the User Manual for more details
Clifford Anderson-Bergman
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | # Building model and modelValues object
simpleModelCode <- nimbleCode({
for(i in 1:100)
x[i] ~ dnorm(0,1)
})
rModel <- nimbleModel(simpleModelCode)
rModelValues <- modelValues(rModel)
#Setting model nodes
rModel$x <- rnorm(100)
#Using nimCopy in R.
nimCopy(from = rModel, to = rModelValues, nodes = 'x', rowTo = 1)
#Use of nimCopy in a simple nimbleFunction
cCopyGen <- nimbleFunction(
setup = function(model, modelValues, nodeNames){},
run = function(){
nimCopy(from = model, to = modelValues, nodes = nodeNames, rowTo = 1)
}
)
rCopy <- cCopyGen(rModel, rModelValues, 'x')
cModel <- compileNimble(rModel)
cCopy <- compileNimble(rCopy, project = rModel)
cModel[['x']] <- rnorm(100)
cCopy() ## execute the copy with the compiled function
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.