I have a model that uses a vector X of constants, some of which are NA. In the model, I calculate a deterministic function like:
x[1:n] <- ifelse(
is.na(X[1:n]),A[1:n],B[1:n])
When X is passed to nimble as a constant, it complains with:
R function '
is.na' has arguments that cannot be evaluated in the code ‘
is.na(X[1:n])'. Either the function must be a nimbleFunction or values for the following inputs must be specified as constants in the model: X[1:n].
The second part of this is misleadingly wrong, because X actually is passed as a constant. Passing as data yields the same.
Note that A and B above are expressions involving random variables and therefore cannot be calculated outside the nimble model.
How should this be handled? Is it possible?
Thanks for your help.
Cheers,
Brook