Warning on some iterations saturated the maximum tree depth of 10

I am fitting a model using rstan, and I set adapt_delta = 0.999 and max_treedepth = 20:

model <- stan_model("model_both.stan")
fit <- sampling(
      model,
      data=data,
      chain=chain,
      iter=iter,
      warmup=warmup,
      cores = chain,
      thin=thin,
      control = list(adapt_delta = 0.999, max_treedepth = 20))

But I got “3815 of 12000 iterations saturated the maximum tree depth of 10 (31.7916666666667%)”. I have set max_treedepth = 20, but the model seems to use the default value of 10?

1 Like

From what I can see in the doc, your approach should work. Fair warning: a max tree depth of 20 means it might take as many as 1 million (2^20) leapfrog steps per iteration, each requiring a gradient calculation.

I don’t understand the RStan doc for sampling(): Draw samples from a Stan model — sampling • rstan

There’s no mention of tree depth, just that ... thing that sends you to the stan doc. I would suggest seeing if the stan() function works and just use that. The sampling() function just uses a compiled model, but the stan() function will auto-compile for you. It may just be the plumbing between them. If that works, the best thing to do would be to report as an issue so somebody realizes it needs to be fixed: Issues · stan-dev/rstan · GitHub

Hi @Kayla, did you figure out what was going on? I’m having the same issue in brms with a cmdstanr backend. I’ve set control = list(max_treedepth=20) but still getting “saturated the maximum tree depth of 10” warnings.