Warning: slice sampler reached maximum number of contractions

534 views
Skip to first unread message

Matthijs Hollanders

unread,
Jun 3, 2021, 3:09:15 AM6/3/21
to nimble-users
Hello all,

I'm trying to see if I can use NIMBLE for a multinomial mixture model with removal sampling data. I followed AHM1 section 7.6 for the Poisson formulation of the multinomial in JAGS instead of the more 'general' formulation of:

y[i, 1:x] ~ dmulti(probs[i, 1:x], N[i])
N[i] ~ dpois (lambda[i])

because 'this construction does not work in BUGS because a random sample size argument is not allowed in the multinomial distribution.' So, I tried fitting this construction in NIMBLE and had no issues until running the MCMC. A slice sampler is assigned to all latent abundance states N and I get warnings for every single node as follows:

Warning: slice sampler reached maximum number of contractions for 'N[5, 17, 8]'. Current parameter value is 2.

I'm not sure what this means and couldn't find this error on this forum. So the previous steps of building and compiling the model are fine but running the MCMC is giving trouble. Is NIMBLE like JAGS that this formulation won't work, or am I making an error elsewhere? By the way, I am initialising N with the total captures at a given site plus a constant, to make sure the model doesn't initialise N to be less than the total number of captures.

Can provide code of course if necessary.

Regards,
Matt

Daniel Turek

unread,
Jun 3, 2021, 6:38:41 AM6/3/21
to Matthijs Hollanders, nimble-users
Matt, good question.  It looks like you're trying to sample the multinomial sample size parameter (N).  The issue I can imagine here is that for:

y[1:x] ~ dmulti( probs[1:x], N )

the necessary condition for this to make sense is that sum(y[1:x]) = N.  That is, the distribution of the N observations across the x categories must sum to N.  As soon as you try to sample N, that is propose and alter the value of N, then this condition fails.  I think that's the issue that the slice sampler is running into, and thus it's unable to sample (propose, or accept a new value for) N.  Does that make sense, or am I missing some part of the problem?

I believe that in the binomial case:

y ~ dbinom(p, N)
N ~ dpois(lambda)

we could in fact sample N, where possible values of N would be N >= y.  But the multinomial case is slightly different as described above.

Does this help?




--
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 nimble-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nimble-users/50c48eef-ee2c-42e6-b8f6-ca7f07375e48n%40googlegroups.com.

Matthijs Hollanders

unread,
Jun 3, 2021, 7:13:58 AM6/3/21
to db...@williams.edu, nimble-users
Hi Daniel,

Thanks for the quick response. That totally helps and is surely the cause of my issue. Is there any reason that the binomial does allow N > y but the multinomial doesn't?

Loving NIMBLE by the way!

Matt

Daniel Turek

unread,
Jun 3, 2021, 7:28:09 AM6/3/21
to Matthijs Hollanders, nimble-users
The short answer would be if we instead defined the binomial (with x=2 categories) as the number of successes *and* the number of failures, as:

y[1:2] ~ dbinom( pSuccess = p, pFailure = 1-p, size = N )

where y[1] + y[2] = N, then it would not work for the binomial, either, since N is subject to this summation constraint again.  But instead, by convention and for simplicity, the binomial is a univariate distribution only giving the number of successes:

y ~ dbinom(pSuccess = p, size = N), 

thus leaving some leeway if you hold y fixed but increased N, and hence we could sample N in this case.

Ben Padilla

unread,
Jun 10, 2022, 7:32:06 PM6/10/22
to nimble-users
Hi All, 
Not sure if responding to an old thread here is a good idea or not, but I am getting a similar warning message on an integrated population model I'm working on. It comes up with estimating abundance in yr based on abundance and survival in yr-1 (eg code below)

  # Sub-adults (1-2yrs)
    nYf[yr] ~ dbin(sAf[yr-1], nJf[yr-1])
    nYm[yr] ~ dbin(sAm[yr-1], nJm[yr-1])
   
    # Adults (≥2yrs)
    nAf[yr] ~ dbin(sAf[yr-1], (nYf[yr-1] + nAf[yr-1]))
    nAm[yr] ~ dbin(sAm[yr-1], (nYm[yr-1] + nAm[yr-1]))

My hunch is that something is going wrong with the priors etc leading in to the estimates of survival of the different age classes. I am kind of basing this off of code from Plard et al 2019, and the ultimate goal is to integrate this with an integral projection model as is done there. Just curious if there are ideas of where to look to get this thing workin! 

Thanks in advance

Abbey Feuka

unread,
Nov 29, 2023, 1:03:53 PM11/29/23
to nimble-users
Hi all,

I'm late to the party, but posting this for reference, in case anyone's in a similar situation. I had a similar problem to Ben and Matt where I was fitting a removal model using a Binomial likelihood (simplified pseudo-code for the relevant portion):

y[i,t] ~ dbinom(p, N[i,t])
delta[i,t] <- lambda[i,t] * (N[i,t-1] - y[i,t-1])
N[i,t] ~ dPois(delta[i,t])

and I was getting the same warning messages about the slice sampler reaching maximum contractions for N (latent population size). It was at weird values for N: as in super high or negative values. I realized it was an issue with both my prior distributions and initial values. Because the model removes individuals from the estimated N at each time step, I needed to specify initial values for N that were sufficiently high enough to not send it into the negatives when animals are removed. I also needed to rein in the priors and starting values for lambda (population growth) to ensure it's staying fairly tightly around 1, and again not sending the population skyrocketing or plummeting at each time step. This took a little bit of simulation because I specified lambda as a function of landscape covariates. 

Hope this is helpful, if anything to my future self when I inevitably come back to these forums to troubleshoot! 

Abbey
Reply all
Reply to author
Forward
0 new messages