nimble-dev / nimble

The base NIMBLE package for R
http://R-nimble.org
BSD 3-Clause "New" or "Revised" License
160 stars 24 forks source link

add Barker proposal sampler #1492

Open paciorek opened 1 month ago

paciorek commented 1 month ago

WIP. For discussion with @danielturek @perrydv before merging.

This adds the Barker proposal sampler as discussed extensively in this NCT issue.

We will need to consider whether to simply add this as another sampler or to replace RW_block as our default block sampler.

See the NCT issue for todo items, primarily testing and documentation.

paciorek commented 1 month ago

I cancelled the workflow since there are no tests to run yet.

paciorek commented 4 weeks ago

One additional thing to consider is whether to use the simpler code without logDetJacobian and the additional nestedness of the gradient-related functions when no param transform is needed. That code is still in the sampler as it's how I originally wrote the sampler. It seems to be somewhat faster in cases where I compared (perhaps 10-20%). That said, I suppose the same question could be raised with HMC too.

paciorek commented 4 weeks ago

I have not implemented the scale/propCov history stuff that is in RW_block. I have implemented setScale and setPropCov.

danielturek commented 3 weeks ago

@paciorek

I like the use of the nimble option to control the default multivariate sampler assignment, and also the choice of name: MCMCuseBarkerAsDefaultMV.

If I'm not mistaken, some of the braces { and } are off in this PR. Is that possibly the case? If so, I'm going to push some minor changes to branch barker.

Definitely ok for not having the facilities for recording the scale and propCov history. Could always be added later, if there's a need.

@paciorek where is the "simpler code" you mentioned, avoiding the additional nestedness of the gradient-related functions? I didn't immediately see what you were referring to. If it really does provide a 10-20% speedup, when no parameter transforms are used, that's maybe worth considering..