slice sampler reached maximum number of contractions

20 views
Skip to first unread message

Sara Euzzor

unread,
Nov 20, 2025, 12:28:03 PMNov 20
to nimble-users
Hi everyone, 

I am trying to fit a quite complex model in Nimble, and when trying to improve the convergence of certain parameters I encountered a problem with the slice sampler. 
I am using a slice sampler for the standard deviations of a spline (modelled as a Multivariate Normal Distribution as specified in Just Another Gibbs Additive Modeler: Interfacing JAGS and mgcv | Journal of Statistical Software ), and the problem arose when I started using an elliptic sampler for the coefficient of said spline. 

The response is a multivariate (3 responses) constrained dataset (represents percentage of people using object A,B,C so should sum to < 1). I am modelling it by transforming into count data and using a beta-binomial distribution. 
I have tried simplifying the model so that it contains only an intercept and a spline for GDP, but the problem persisted. 

As a last resort, I am simulating response data using a known intercept, standard deviation (which is then used to simulate known spline coefficients), and concentration (to control the variability of the beta-binomial).  
I am then fitting the model. The error message still comes up. Most parameters are retrieved correctly from the model. The first standard deviation (which penalizes the wigglines of the non-linear basis functions) always ends up converging at 0 though. 

I have included the Rscript with the simulated code. Can anyone spot any mistakes or find a cause of the problems with the slice sampler? I have noticed that it fails when the current value is a point of maximum of the posterior density but can't really find a theoretical justification for that.

Many thanks, 
Sara

simulated data.R

Chris Paciorek

unread,
Nov 26, 2025, 1:52:18 PMNov 26
to Sara Euzzor, nimble-users
Hi Sara,

It looks like the lambda values are getting stuck in the slice sampling. They stay at the same value for multiple iterations. I think this is when the warnings about contractions are emitted. I suspect it's because somehow the values of the b_gdp values are such that other possible lambda values are not feasible, so that both lambda values get stuck until the b_gdp values shift some. I don't know why this particular combination of samplers is causing that to happen. Another difficulty is that in some cases lambda_1 seems to drift down towards zero and not sample from larger values after it does that.

You might try HMC via nimbleHMC here. I tried it briefly and it seems to help somewhat, but still mixes slowly for some of the parameters (particularly lambda_1) so you may need to run it for a while. If you try it you need to add `buildDerivs=TRUE` as the last argument when creating `dmybetabin3` and calling `nimbleModel`.

-chris

--
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/7ee084a5-561a-4328-95f7-c0ed5c083e6bn%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages