`nimbleHMC()` error: "must set `buildDerivs = TRUE` when building model" when the model is created using `readBUGSmodel()`
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.
@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 @perrydv looks like we never resolved this. I'm going to add the argument to readBUGSmodel unless there are objections.
@paciorek Agreed, thank you.