Hi all,
I'm developing an R package that fits Bayesian single-index models using nimble as the backend. The package registers custom distributions, custom samplers, and helper nimbleFunctions, all defined via nimbleFunction() and used inside nimbleModel() / compileNimble() / nimbleMCMC().
In my current implementation, these objects are assigned to .GlobalEnv at the start of each fitting call and removed on exit, because this is the only setup under which compilation succeeds. Defining them inside a local function environment, a dedicated package environment, or the package namespace causes compilation to fail.
I'd like to move away from this for two reasons: (i) writing to .GlobalEnv from a package call can silently overwrite user objects with the same name, and (ii) exposing internal nimbleFunctions in the user's workspace is confusing for package users.
My questions:
Any pointers to packages that embed nimble this way, or to relevant sections of the manual, would be very helpful.
Thanks in advance,
Seowoo Jung