nimble-dev / nimbleEcology

18 stars 9 forks source link

`nimbleOccu` use of `nimbleHMC` via `suggests` #30

Open paciorek opened 1 month ago

paciorek commented 1 month ago

We're currently planning to include a wrapper function, nimbleOccu, to provide lme4-like interface for setting up occupancy models using macros and (optionally) running MCMC.

If we try to use nimbleHMC via suggests, sampler_NUTS is not found when invoking configureHMC.

@kenkellner I think a work-around is to do this (avoiding configureHMC, which is just a convenience wrapper):

    conf <- configureMCMC(mod, nodes = NULL, print = FALSE)
    conf$addSampler(nimbleHMC::sampler_NUTS, target = 'mu',
                    control = list(warmupMode = "iterations", warmup=100))

That way sampler_NUTS is found via namespace resolution within nimbleOccu and passed in, so that we're not trying to find it from within nimble's MCMC configuration code, which does not know about nimbleHMC namespace objects.

I'm going to file an issue on nimbleHMC to consider the more general issue that this reveals.

kenkellner commented 1 month ago

I can confirm this works (7bafb64fda76f5b02b19cf392e72fc52a3834865).