configuring sampler for a subset of elements of an array

16 views
Skip to first unread message

Torbjørn Ergon

unread,
Dec 14, 2025, 11:04:29 AM (4 days ago) Dec 14
to nimble-users
Hi all,

I'm working a a spatial model. The default samplers are: 

posterior_predictive sampler (2301) - z[] (2288 elements) - x[] (13 multivariate elements) binary sampler (9882) - z.cam[] (440 elements) - z[] (9442 elements) RW_block sampler (85) - x[] (85 multivariate elements) RW sampler (77)
...

I get very bad mixing and want to adjust 'adaptFactorExponent' for the RW_block sampler. x[] is an array of the spatial random effects for 138 sites, 14 occasions, and 7 species. Because some site-occasion combinations are not sampled, some elements of x[] have a posterior_predictive sampler. It will be extremely complicated to avoid this since we are not allowed to use vector indices to vectors and matrices (for dmnorm()). The following fails,

conf$removeSamplers('x[1:138, 1:14, 1:7]')
conf$addSampler('x[1:138, 1:14, 1:7]', 'RW_block', control = list(adaptFactorExponent = 0.25))

because that removes the  posterior_predictive samplers.

Is there an easy way to access only the nodes in x[] that have the 'RW_block' sampler?

Cheers,
Torbjørn

Daniel Turek

unread,
Dec 14, 2025, 12:03:09 PM (4 days ago) Dec 14
to Torbjørn Ergon, nimble-users
When you first call configureMCMC, try passing the control list argument as:

conf <- configureMCMC(model, ..., control = list(adaptFactorExponent = 0.25))

I believe that will pass the control argument "adaptFactorExponent = 0.25" to all samplers which are assigned, so that should catch all the RW_block samplers which are assigned by default (without affecting the predictive samplers).

Cheers,
Daniel


--
You received this message because you are subscribed to the Google Groups "nimble-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nimble-users...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/nimble-users/1f8d1a2f-5ae4-4a7f-bbd8-1d204ffc4e42n%40googlegroups.com.

Torbjørn Ergon

unread,
Dec 14, 2025, 1:52:25 PM (4 days ago) Dec 14
to nimble-users
Thanks Daniel! That worked!

Still poor mixing though. I.e., low autocorrelation within chains and each chain seems stationary, but they converge to different distributions. Not sure what that indicates?

Torbjørn

Chris Paciorek

unread,
Dec 16, 2025, 8:12:36 PM (2 days ago) Dec 16
to Torbjørn Ergon, nimble-users
You might try the HMC sampler or the "Barker" sampler.

Reply all
Reply to author
Forward
0 new messages