Hi,
I'm trying to write a model with a vectorized normal distribution, and I'm getting the following error after compileNimble(): "Error: Problem with type of arg1 in sizeBinaryCwise."
The error doesn't occur when I use dnorm() with a for loop, so I'm assuming the error is related to the following functions and parts of the model code:
#function for vectorized normal distribution -- all means = 0
dnorm_vector <- nimbleFunction(
run = function( x = double(1),
sd = double(1),
nsite = double(0),
log = integer(0, default = 0)
) {
returnType(double(0))
logProb <- sum(dnorm(x, mean = rep(0,nsite), sd = sd, log = TRUE))
if(log) return(logProb) else return(exp(logProb))
})
#row sums function
rowsum <- nimbleFunction(
run = function( matrix = double(2),
nsite = double(0))
{
returnType(double(1))
out <- rep(NA,nsite)
for(i in 1:nsite){
out[i] <- sum(matrix[i,])
}
return(out)
}
)
model_code <- nimbleCode({
#process error
for(t in 1:ntime){
proc_error[t,1:nsite] ~ dnorm_vector(sd=rowsum(N[t,1:nsite,1:nsize], nsite) * proc_CV, nsite=nsite)
}
})
Does anyone have any suggestions for what could be causing this error during C++ compilation?
Thanks!
Abby K.