Open drnickisaac opened 1 year ago
Thinking about this some more, I'm wondering whether in fact it may be more straightforward that we thought. Some suggestions:
method="jags"
length(taxa_name)
= 0 method="nimble"
zst
to much laterbugs_data
(until later)If we go down this route, we would also have to figure out how to do this in parallel.
This all sounds reasonable. An alternative however would be a function that wraps around occDetFunc
and runs it for each species. Then this new function could have a compileOnce = TRUE
argument. The function would then step through occDetFunc for the first species (the first species that doesn't drop out) and return the compiled model. This compiled model could then be fed in to occDetFunc
for all species within the new function.
I've started implementing this on my version of the Nimble branch.
There are several hundred lines of code that generate the bugs_data
object: I've put these into a new function called prepOccData()
I've separately wrapped the code that generates BUGS code (including the Nimble version) into a function getBUGScode()
that permits writing to the screen.
This should make it easier to work with editing the Nimble version.
Once that is done, we'll want to edit the code in order to make it compatible with multiple species.
To gain the full benefit of Nimble, we could change the structure of sparta such that the model is compiled only once, then applied to each species in turn. This could really cut down on runtime.
To start scoping out the challenge, I made a list of all the points in occDetFunc where the identity of the species actually matters.
occDetData
. Based on this, there is a decision whether to proceed , which is implemented at line 242. If the species doesn't have enough data, subsequent steps are omitted.Changing occDetFunc so that it works with multiple species would be quite challenging.
Much of the code between lines 234 and 366 is associated with setting up of the vectors defining Regions and regional aggregates. Perhaps these could be placed into a separate function. Probably this is a general solution to make the challenge clearer: package up individual sections of the code and put them elsewhere. Then the critical dependencies will become clearer.