Hi Nimble team,
I am trying to test for an effect of food availability on survival (specifically mortality hazard rates) in a capture-recapture (CR) model. Since no clean covariate for food availability is available, I built a model to estimate food availability in each year from raw and messy data. This model on its own runs fine (~20 min), as well as the CR model on its own (~10h). But when I include the food availability module in the CR model, and include an effect of (estimated) food availability on mortality hazard rates, suddenly the model takes much longer to compile (buildMCMC() and compileNimble() steps), requires way more memory, and takes much longer to run.
I made a test with a simulated dataset of modest size (15 years, 30 marked individuals per year, food availability data), and I confirmed that when I include both the CR module and the food module in a single model without including a parameter for an effect of food on mortality, my whole script takes ~30 mins to run. But when I include a parameter for an effect of acorn on mortality, the buildMCMC() and compileNimble() steps last ~5 minutes each instead of seconds, and the model takes >12 hours to run. With my real dataset (30 years of data, ~100 marked individuals in each year), the model becomes prohibitively slow.
Is this to be expected? Is it related to the specifics of my food availability model? Is there a way to speed things up? Any insight would be appreciated.
The model code and the code to simulate data is attached.
Thanks in advance,
Marwan
--
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/0b2610cb-1ce7-4f21-95ca-6adf248eda3bn%40googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/nimble-users/334ff054-4ebc-4896-97a4-210907d837cbn%40googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/nimble-users/c8f719fe-1970-47e2-a6cf-9ec26dc35119n%40googlegroups.com.
Hi Perry,
Thanks a lot for your answer! Sorry for the delayed response, I was busy with other projects.
I removed zeta from the model and instead used a nimbleFunction that returns lik[i], as you suggested. In the standard CR model (without the additional food module), using this tricks halved the run time (I’m going to use it in other contexts, thanks a lot!). In the model with the food module, the compilation stage was fast (20 minutes), however the MCMC was still prohibitively slow (after more than 7 hours, the first ‘-‘ of the progression bar had still not appeared). So I will default to running the food model and the CR model sequentially.
I also tried removing the E array (i.e., compute it in the nimbleFunction) since it was indexed by both i (individuals, many of them) and t. Strangely enough, it roughly doubled the run time (the compilation time was similar or lower) of the standard CR model. Does that make sense?
In the code with my actual data, I already combine duplicate capture histories, so no room for improvement there.
Regarding the acorn_obs[i, t, k], they are indeed data but some are missing so they are sampled by the MCMC. Not sure if this affects the run time substantially.
Many thanks,
Marwan