Hello,

I have recently switched to JAGS in an attempt to speed up the run time of some analysis I am doing. The time saved is incredible, I'm delighted! BUT, now I keep getting the following error message:

Error: Error in node `N_juv[66,3]`

Failure to calculate log density

I figured it may be something to do with my starting values but I have spent a long time tweaking these but continue to get the same message. Incidentally, the numbers of the indexing (in this case `[66,3]`

) change each time. I was wondering if there is an obvious reason for this error message??

I have pasted the code below in case it is not a straight forward fix.

Many thanks in advance

model{ #Priors psi1 ~ dunif(0, 1) alpha ~ dnorm(0.001, 0.001) mu_b0A ~ dnorm(0, 0.001) mu_b1A ~ dnorm(0, 0.001) mu_b1J ~ dnorm(0, 0.001) mu_g0 ~ dnorm(0, 0.001) mu_g1 ~ dnorm(0, 0.001) mu_om ~ dnorm(0, 0.001) p ~ dunif(0,1) #tau_e ~ dgamma(0.001, 0.001) tau_om ~ dgamma(0.001, 0.001) tau_b0A ~ dgamma(0.001, 0.001) tau_b1A ~ dgamma(0.001, 0.001) tau_g0 ~ dgamma(0.001, 0.001) tau_g1 ~ dgamma(0.001, 0.001) bet0_A[nyear] ~ dnorm(mu_b0A, tau_b0A) bet1_A[nyear] ~ dnorm(mu_b1A, tau_b1A) for(k in 1:(nyear-1)){ o[k] ~ dnorm(mu_om,tau_om) omega[k] <- exp(o[k]) bet0_A[k] ~ dnorm(mu_b0A, tau_b0A) bet1_A[k] ~ dnorm(mu_b1A, tau_b1A) gam0[k] ~ dnorm(mu_g0, tau_g0) gam1[k] ~ dnorm(mu_g1, tau_g1) phi[k] ~ dunif(0,1) } #Year 1 for(m in 1:nsite){ z[m,1] ~ dbern(psi1) #Adult ~ patch length N_ad[m,1] ~ dpois(lambda_A[m,1]) log(lambda_A[m,1]) <- bet0_A[1] + bet1_A[1] * length[m] zA[m,1] <- z[m,1] * N_ad[m,1] #Juv ~ adult N_juv[m,1] ~ dpois(lambda_J[m,1]) log(lambda_J[m,1]) <- mu_b1J * zA[m,1] zJ[m,1] <- z[m,1] * N_juv[m,1] #connectivity for(n in 1:nsite){ con[m,n] <- exp(-alpha * dmat[m,n]) * (1 - equals(IND[m],IND[n])) } } #Ecological submodel for(k in 2:nyear){ for(i in 1:nsite){ #Calculate colonisation as a function of by per patch connectivity to N_J col[i,k-1] <- 1 - exp(-omega[k-1] *(inprod(zJ[,k-1],con[i,]))) #Calculate extinction as a function of N_A logit(ext[i,k-1]) <- gam0[k-1] + gam1[k-1] * zA[i,k-1] #Calculate occupancy probability WITH a rescue effect muZ[i,k] <- z[i,k-1] * ext[i,k-1] + (1 - z[i,k-1]) * col[i,k-1] z[i,k] ~ dbern(muZ[i,k]) #Adult ~ patch length N_ad[i,k] ~ dpois(lambda_A[i,k]) log(lambda_A[i,k]) <- bet0_A[k] + bet1_A[k] * length[i] zA[i,k] <- z[i,k] * N_ad[i,k] #Juv ~ adult N_juv[i,k] ~ dpois(lambda_J[i,k]) log(lambda_J[i,k]) <- mu_b1J * N_ad[i,k] zJ[i,k] <- z[i,k] * N_juv[i,k] }#k }#i # Observation model for(i in 1:nsite){ for(k in 1:nyear){ for(j in 1:REPS[i,k]){ muy[i,j,k] <- z[i,k] * p x[i,j,k] ~ dbern(muy[i,j,k]) }#j }#k }#i n.occ[1]<-sum(z[1:nsite,1]) for (k in 2:nyear){ n.occ[k] <- sum(z[1:nsite,k]) }#k }#end

Last edit: Martyn Plummer 2012-11-18