error when configuring MCMC

Skip to first unread message

May 17, 2023, 4:45:02 PM5/17/23
to nimble-users
Hi all, 

I am brand new to Nimble (even tho I have been using OpenBUGS and JAgs for a while)

I have written a daily CMR model and have managed to compile it, however when I attempt to configure the MCMC i get the following error message:

Error in if (max(numPaths) > sum(numDeps)) { : missing value where TRUE/FALSE needed

I cant seem to find anything pointing to this error, does anyone has the slightest idea what I should be looking for to fix this ?



Ben Goldstein

May 17, 2023, 4:51:12 PM5/17/23
to, nimble-users
Hi Guillaume,

The message "missing value where TRUE/FALSE needed" usually means that there's a logical statement in your model code with an NA value that's trying to be evaluated. I'm not sure why this would happen at the MCMC configuration step. Is the code in the error message "if (max(numPaths) > sum(numDeps))" a line in code you wrote? My guess is either max(numPaths) and/or sum(numDeps) is NA whenever this line is being called (which would be the case if either vector contains at least one NA element).

If you're able to provide a reproducible example I could try to help with more specifics.


You received this message because you are subscribed to the Google Groups "nimble-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To view this discussion on the web visit

Chris Paciorek

May 17, 2023, 5:24:48 PM5/17/23
to Ben Goldstein,, nimble-users
it looks like the code in the error message is coming from our MCMC conjugacy checking system. So getting a reproducible example to help us track down why that is happening will be helpful.


May 17, 2023, 5:40:09 PM5/17/23
to nimble-users
Hi Ben,

Thanks for the quick answer.
A bit of background, I have some CMR data of smolts migrating out of the freshwater system but the CMR experiments sometime start when smolts have started migrating.
this means that some years there is a fraction of the run that we don't sample, so I am also trying to model this process too based on years when we have confidence that we capture the whole run (i.e.  

I have a model that runs in jags but its very slow to converge and that's why I'm trying to switch to Nimble.
I tried just copy-pasting the jags code but I have already picked up on some things I will have to change in terms of data.frame formatting so that's why Im just slowly building the model in Nimble and the version I'm sharing here just has the daily abundances:
and the fisrt captures:
data_RT[i] ~ dbin(q[i] , Nm[I_RT_y[i]])

I am not expecting anything from the inference process at this point, just trying to understand how to adjust my coding 


May 18, 2023, 9:40:21 AM5/18/23
to nimble-users
So slowly removing bits of code to identify the source of the issue it seems like  this block is the source of some issue

  ## Expected proportion of smolt leaving on day i  (centering)
   P_sm[1] <- p[1]
  for(i in 2:I_nDays_min1){
      P_sm[i] <- (1-sum(P_sm[1:(i-1)])) * p[i]
  P_sm[I_nDays] <- 1-sum(P_sm[1:I_nDays_min1])

p[i] is the probability to leave the system on day[i]
and P_sm[i] is the proportion of the total smolt population leaving on day i

i have read that dynamic indexing is different in nimble so could that be the issue here ?

Chris Paciorek

May 19, 2023, 11:57:05 AM5/19/23
to, nimble-users
Hi Guillaume,

It looks like this is a bug in our conjugacy checking. I don't see any dynamic indexing in your model, so I don't think it relates to that. (i.e., no cases where an index is not a fixed value, but I could be overlooking something)

We'll figure out what is going wrong, but in the interim, you can get the MCMC to configure by turning off conjugacy checking:

configureMCMC(modelName, useConjugacy = FALSE)
# or
buildMCMC(modelName, useConjugacy = FALSE)


May 19, 2023, 12:18:07 PM5/19/23
to nimble-users
Hi Chris,

Thanks a bunch for looking into this, i was able to run the MCMC when turning the conjugacy checking off!


Chris Paciorek

May 20, 2023, 12:40:30 PM5/20/23
to, nimble-users
Just to wrap this up -- in our conjugacy checking we have processing that tries to figure out the most efficient way to check conjugacy.
It turns out that this processing had numerical issues in handling incremental sums structure such as found for `P_sm` in Guillaume's model.
We're fixing this and the fix will appear in our next release, which should appear very soon.


Reply all
Reply to author
0 new messages