Hi!
I'm trying to use HMC to help with sampling a spatial gaussian process, and I am getting some errors when compiling with compileNimble(myModel) -- I wasn't getting these errors before using HMC, and I'm imagining that they are from building derivatives. Based on printErrors() and looking through the temporary directory created by nimble, I think at least one error is coming from this function:
#write function for calculating capture probabilities
calc_prob <- nimbleFunction(
#input and output types
run = function(nobs = double(0), # scalar
nsize = double(0), #scalar
hazard = double(2)) # 2-d array
{
returnType(double(1)) # 1-d array return
#create empty array
p <- rep(NA,nsize)
#loop through sizes
for(k in 1:nsize){
#1-exp(-P(captured at all))
p[k] <- 1-exp(-sum(hazard[1:nobs,k]))
}
return(p)
},
buildDerivs = TRUE
)
Many error messages refer to "Interm_1082", and in a file in the temporary nimble directory, I'm finding that this refers to:
Is there something incompatible with building derivatives and taking the exponent of a sum of a vector?
I'm also having trouble parsing through all the error messages, so I've attached my code in case the errors are referring to something else. The nimble functions and model code are at the top, and building the model begins on line 552.
I think I've replaced all of the discrete distributions with continuous distributions, so I'm wondering if there's anything else I should be looking out for when trying to use HMC?
Thanks so much as always for your help!
Best,
Abby