HMC and configureRJ

9 views
Skip to first unread message

Eduardo Guimarães Martins

unread,
Jun 6, 2024, 11:57:06 PMJun 6
to nimble-users
Hi there,

Whenever I try and using indicator variables with HMC, I get an error and warning from configureRJ() that there are no samplers for the parameters I'm associating with the indicator variables (see message below). The indicator variable approach with configureRJ() works fine if I don't use HMC. Does configureRJ() not work when using HMC? I coudn't find any reference to this issue using the keywords HMC and configureRJ in the list. Thanks for any help.

Error in currentConf[[1]] : subscript out of bounds
In addition: Warning message:
In configureRJ(conf = conf_hmc, targetNodes = c("beta_mu_sps_FEM",  :
  configureRJ: There are no samplers for 'beta_mu_sps_TEMP'. Skipping it.

Eduardo

Daniel Turek

unread,
Jun 9, 2024, 6:40:08 AMJun 9
to Eduardo Guimarães Martins, nimble-users
Eduardo, thanks for raising this question.  You're right, there most likely are cases where nimble's RJMCMC doesn't necessarily work alongside the HMC sampler.  Issues could relate to the HMC sampler updating many dimensions of the model, while RJMCMC is designed to work with samplers operating on single model parameters; and also, that the RJMCMC functions are general to work across all model dimensions, while the HMC sampler has some inherent restrictions (for example, it can only operate on model distributions with AD support).  So, you're probably quite right, that there could be cases which don't work when trying to use both.

That said, from your email I didn't entirely understand what you're trying to do, and how this error is arising.  Is it possible for you to provide a reproducible example?  That would help understand the exact problem you're having.

Thanks,
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 on the web visit https://groups.google.com/d/msgid/nimble-users/d7d5f686-b485-4829-9288-7a1ff99ddbf0n%40googlegroups.com.

Eduardo Guimarães Martins

unread,
Jun 18, 2024, 2:40:28 PM (11 days ago) Jun 18
to Daniel Turek, nimble-users

Hi Daniel,

 

Thanks for the helpful response and sorry for the delay in getting back to you. I created a simple example (attached) that reproduces the error I get in my real data analysis. In this example, the error occurs when using HMC and RJMCMC indicator variable selection with TWO variables (x1 and x2).

 

However, when I initially created the example with a single variable (x1), I could not reproduce the error and the code finished running without any problems. Oddly, although samplers were assigned to the indicator variable, the output didn’t contain any samples for it (even though I include it in the list of what to monitor), whereas the hyperprior for the indicator probability (d1) was being monitored (even though I did not include it as a variable to monitor). This is happening even when I don’t use HMC.  I had not run into this issue with my data analysis before, but haven’t re-run my analysis after installing nimble 1.1.0, which I did before creating this reproducible example.

 

Thanks again,

 

Eduardo

HMC_example.R

Chris Paciorek

unread,
Jun 24, 2024, 2:23:48 PM (5 days ago) Jun 24
to Eduardo Guimarães Martins, Daniel Turek, nimble-users
Hi Eduardo,

Sorry about our slow response. You've caught us at a time where the
developer team has some travel.

I've looked at this a bit and it looks to me that the RJMCMC sampler
cannot work with a multivariate sampler (such as HMC but possibly
other samplers) on the target nodes that are being considered as to
whether they should be included in the model or not.

To explain further, let me say more about how our RJMCMC sampling works.

- It assumes that each target node (such as your 'b1' or 'b2') has a
separate sampler assigned to them.
- When the RJMCMC sampling is added to the MCMC configuration, we set
things up so that the sampler on a given target node is only called
if the target node is currently in the model. If it is not, the target
node is not sampled.

Given that, if there is a single (multivariate) sampler assigned to
multiple target nodes, it's not consistent with the RJMCMC sampling.
Consider an MCMC iteration in which 'b1' is in the model and 'b2' is
not in the model. Then any multivariate sampler on {b0,b1,b2} doesn't
make sense because only 'b0' and 'b1' are in the model and nimble
cannot automatically run an HMC sampler only on {b0,b1}.

Part of the problem here is that we did not anticipate that a
multivariate sampler might be assigned to the target node(s) in RJMCMC
sampling. We should put in some additional checking to check that
each target node has a single scalar sampler assigned to it. I will
make a note for us to do this.

I will also say that I did not look carefully at your scenario of
having a single variable ('x1'). But I can say that it would not work
to have an HMC sampler on 'b0' and 'b1' for the reasons I describe
above - namely that if 'b1` is not in the model for a given MCMC
iteration, nimble cannot run an HMC sampler only on {b0}.

-chris

On Tue, Jun 18, 2024 at 9:40 PM Eduardo Guimarães Martins
> To view this discussion on the web visit https://groups.google.com/d/msgid/nimble-users/DM4P221MB0881DC8EC037560E6DC669ECFDCC2%40DM4P221MB0881.NAMP221.PROD.OUTLOOK.COM.
Reply all
Reply to author
Forward
0 new messages