Max_treedepth and target_accept issue

Hello All:

I am currently engaged in the development of a hierarchical Bayesian mixture model. During this process, I have encountered warning messages related to max_treedepth and target_accept. To address these issues, I’ve introduced specific arguments into my code. Despite adjusting the max_treedepth to 30, my chains continue to encounter the max_treedepth issue, which is perplexing as it occurs even when the depth is below the value I set (as illustrated in the figure below). Moreover, I have increased the target_accept parameter from 0.99 to 0.9999. However, this adjustment does not seem to impact the sampling speed, leading me to suspect that the target_accept parameter might not be updating correctly. I have attempted to implement these arguments in two different ways, but unfortunately, neither approach has been successful.

Would you please see if my code/approach has some problems?

Thanks for your advice from this community,

Jay

trace = pm.sampling.mcmc.sample(draws = n_draws, tune = n_tune, 
chains = n_chains, cores = n_cores, init = "advi+adapt_diag",
step = [pm.NUTS()], nuts_sampler_kwargs = {"max_treedepth": n_treedepth, 
"step_scale": step, "target_accept": score_mcmc}, random_seed = seed, progressbar= bar_status);

trace = pm.sampling.mcmc.sample(draws = n_draws, tune = n_tune, 
chains = n_chains, cores = n_cores, init = "advi+adapt_diag", 
step = [pm.NUTS(max_treedepth = n_treedepth, step_scale = step, 
target_accept = score_mcmc)], random_seed = seed, progressbar= bar_status);

image

@Gumibear_Toronto I have never changed max_treedepth, but I believe you have to pass the kwargs you want for your nuts sampler as nuts={...}. the nuts_sampler_kwargs are for external nuts samplers, which is confusing.

More importantly, if you find yourself having to change max_treedepth and target_accept so much, that is often indicative of a model issue that should be addressed directly, before resorting to changing the sampler knobs.

1 Like

+1, also note that max_treedepth = 30 means you are potentially doing this much leapfrog:

2 Likes

Thank you both. I will retry this way to imply the arguments.