if (FALSE) {
## Say we want an R function that adds 2 to every value in a vector
add2 <- function(x) {
x + 2
}
Radd2 <- nimbleRcall(function(x = double(1)){}, Rfun = 'add2',
returnType = double(1))
demoCode <- nimbleCode({
for(i in 1:4) {x[i] ~ dnorm(0,1)}
z[1:4] <- Radd2(x[1:4])
})
demoModel <- nimbleModel(demoCode, inits = list(x = rnorm(4)),
check = FALSE, calculate = FALSE)
CdemoModel <- compileNimble(demoModel)
}
Run the code above in your browser using DataLab