Issues initializing and IPM with true simulated values

16 views
Skip to first unread message

Marwan Naciri

unread,
Aug 17, 2026, 1:37:28 AM (11 days ago) Aug 17
to nimble-users

Hi nimble team,

I’m trying to run simulations for an Integrated Population Model (IPM). I simulate data from the nimble model, and this step seems to work fine. But then, when I try to analyze the data with the same IPM (except for one difference, the capture-recapture likelihood is marginalized in the model code I use to analyze the data), I get initialization problems (warning: problem initializing stochastic node N_DS_not_aged[2, 1, 1]: logProb is -Inf), followed by warnings that the slice sampler has reached the maximum number of contractions for various nodes.

What I can’t make sense of is that I’m using as initial values the values extracted from the nimble object used to generate the data. I manually checked initial values that are not correctly initialized, and I can’t see any issue with them. Another surprising outcome is that the nodes with initialization problems are not the same from one run to the next, although I provide fixed initial values for all demographic rates and initial population size.

Any idea what can cause that? Attached is a code to generate a dummy-sized dataset and to fit the IPM, that produces the above-mentioned problems (with potential lucky runs without any initialization issues).

Also, if anyone has a follow-up on how to use a nimble function to calculate the marginalized likelihood of a capture-recapture dataset without creating the transition and detection matrices (https://groups.google.com/g/nimble-users/c/aal_iug1J1k/m/8Eqyx-UoAgAJ), I’d be very grateful.

Many thanks in advance,

Marwan


IPM_simulation_reproducible_exemple.R

Wei Zhang

unread,
Aug 20, 2026, 3:06:30 AM (8 days ago) Aug 20
to Marwan Naciri, nimble-users
Hi Marwan,

I may not follow the whole model structure, so I am not sure if the mcmc results I got make sense. The -Inf logProb issue seems to come from the incomplete initialisation setup. You provided an initial value for N_DS_bef_aging but did not provide values for some stochastic nodes that are parents of N_DS_bef_aging. I added the following into your inits function:
  N_piglets_CR = IPM$N_piglets_CR,
  N_piglets_f_remov = IPM$N_piglets_f_remov,
  N_subad_unk_remov_f = IPM$N_subad_unk_remov_f,
  N_ad_age_2_remov = IPM$N_ad_age_2_remov,

The issue arose because in you code you had

N_DS_bef_aging[2, 1, 1] ~ dbin( prob = s_CR_to_DS[2, 1, 1], size = N_post_remov[2, 1, 1])
and
N_post_remov[2, 1, 1] <- N_CR[2, 1, 1] - N_ad_age_2_remov[1, 1] 

You did not provide any initial value for N_ad_age_2_remov, and then it was generated using the prior which may conflict with other initial values you provided, e.g. N_post_remov is smaller than N_DS_bef_aging

Then your script runs ok, with one warning: value in right-hand-side-only variable is NA or NaN, in variable: CH. This should be something not related to the logProb issue. I will take another look. 

Hope this makes sense. 

Best wishes,
Wei

--
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 visit https://groups.google.com/d/msgid/nimble-users/e1c65b54-177c-478c-8463-22c7e3699653n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages