nimble icon indicating copy to clipboard operation
nimble copied to clipboard

`nimbleHMC()` error: "must set `buildDerivs = TRUE` when building model" when the model is created using `readBUGSmodel()`

Open pehkawn opened this issue 1 year ago • 3 comments

According to the Nimble user guide, automatic differentiation (AD) is needed when using HMC (nimbleHMC::nimbleHMC()).

When building a model using nimbleModel(), AD can be enabled by setting the function argument buildDerivs = TRUE. However, when building the model using readBUGSmodel(), there's seemingly no option for enabling AD.

Consequentially, I get the error message:

Error: must set buildDerivs = TRUE when building model

when running nimbleHMC() on my BUGS model.

~I was therefore wondering if there's another way of enabling AD, when reading in a BUGS model file?~

As a feature suggestion, it would be an improvement if buildDerivs were to be added to available options in either nimbleHMC() or readBUGSmodel().


[Edit:]

I just realized I can enable AD for all models by setting nimbleOptions(buildModelDerivs = TRUE). However, I do not know the implications of having AD globally enabled. Still, it would be a nice feature to enable AD for the model only.

pehkawn avatar Jan 17 '24 13:01 pehkawn

@perrydv It seems reasonable to add this buildDerivs argument to readBUGSmodel.

I'd be happy to make this quick change, but let me know what you think.

danielturek avatar Jan 17 '24 20:01 danielturek

@danielturek @perrydv looks like we never resolved this. I'm going to add the argument to readBUGSmodel unless there are objections.

paciorek avatar Jan 30 '24 17:01 paciorek

@paciorek Agreed, thank you.

danielturek avatar Jan 30 '24 18:01 danielturek