extracting variance of proposal density from an adaptive MH

20 views
Skip to first unread message

Sara Euzzor

unread,
Apr 28, 2025, 1:02:03 PM4/28/25
to nimble-users
Hi everyone, 

I'm trying to fix the convergence of some parameters and to do so I wanted to check what was the final value of the variance of the proposal distribution after adaptation for said parameters.
I've been trying to do that using the $getSampler() command on the mcmc configuration and checking the "control" list, but it is always empty. Additionally I get these warnings, which I think suggest that some information is being lost in the transcription form R to C++ and back (which I'm guessing is why the "control" list is empty). I tried to change the way I compile the model and mcmc (compiling the mcmc both with the compiled and uncompiled model as project), but I keep getting the same warnings. 
Does anyone have any idea what might be going wrong? 

image

Perry de Valpine

unread,
Apr 28, 2025, 1:11:20 PM4/28/25
to Sara Euzzor, nimble-users
Hi Sara,

Thanks for the question. The mcmc configuration exists only in R. After the MCMC has been built, the configuration has no further role. The control list is used for input but does not get updated or collect output in any way. Here are the steps you can take to see the internal variables of samplers.

nimbleOptions(buildInterfacesForCompiledNestedNimbleFunctions=TRUE)
# build, compile, and run your MCMC
# Then access internals like this
compiled_mcmc$samplerFunctions[[1]]$scale
# if, for example the first sampler is an adaptive random-walk Metropolis-Hastings, for which "scale" is the proposal std. dev.

To see what variables exist in each sampler, you would need to look at the source code in MCMC_samplers.R. 

We refer to an object such as "compiled_mcmc" as an interface because it exists to access (interface to) a C++ object. We refer to an object such as "samplerFunctions[[1]]" as being nested since it lives only within compiled_mcmc. We do not by default build the interface for samplerFunctions[[1]] that allows you to do samplerFunctions[[1]]$scale because that creates a lot of overhead and is rarely needed. Hence the (verbosely named) nimbleOption will build any nested interfaces and you can thereby access the internal variables of any of the samplers.

HTH
Perry


--
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/1b08e10f-293f-4317-8856-c2b10a196516n%40googlegroups.com.

Sara Euzzor

unread,
May 6, 2025, 6:05:35 AM5/6/25
to nimble-users
Hi Perry, 
Many thanks for your help!
Sara

Reply all
Reply to author
Forward
0 new messages