R: Creates a nimbleFunction for setting the value of a scalar...

setAndCalculateOne {nimble} | R Documentation

## Creates a nimbleFunction for setting the value of a scalar model node, calculating the associated deterministic dependents and logProb values, and returning the total sum log-probability.

### Description

This nimbleFunction generator must be specialized to any model object and any scalar model node. A specialized instance of this nimbleFunction will set the value of the target node in the specified model, calculate the associated logProb, calculate the values of any deterministic dependents, calculate the logProbs of any stochastic dependents, and return the sum log-probability associated with the target node and all stochastic dependent nodes.

### Usage

    setAndCalculateOne(model, targetNode)

### Arguments

`model` | An uncompiled or compiled NIMBLE model. This argument is required.
`targetNode` | The character name of any scalar node in the model object. This argument is required.

### Details

Calling setAndCalculateOne(model, targetNode) will return a function with a single, required argument:

targetValue: The numeric value which will be put into the target node, in the specified model object.

### Author(s)

Daniel Turek

### Examples

    code <- nimbleCode({ for(i in 1:3) x[i] ~ dnorm(0, 1) })
    Rmodel <- nimbleModel(code)
    my_setAndCalc <- setAndCalculateOne(Rmodel, 'x[1]')
    lp <- my_setAndCalc$run(2)

[Package nimble version 0.9.1 Index]