Skip to content

Commit f5d8298

Browse files
committed
update recommendations for responding to convergence warnings
1 parent ea74bc7 commit f5d8298

1 file changed

Lines changed: 14 additions & 5 deletions

File tree

vignettes/rstanarm.Rmd

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -334,15 +334,16 @@ the relevant issues.
334334

335335
### Markov chains did not converge
336336

337-
__Recommendation:__ run the chains for more iterations. <br>
337+
__Recommendation:__ run the chains for more iterations (in certain cases, see qualification below). <br>
338338

339339
By default, all __rstanarm__ modeling functions will run four randomly
340340
initialized Markov chains, each for 2000 iterations (including a warmup period
341341
of 1000 iterations that is discarded). All chains must converge to the target
342342
distribution for inferences to be valid. For most models, the default settings
343343
are sufficient, but if you see a warning message about Markov chains not
344344
converging, the first thing to try is increasing the number of iterations. This
345-
can be done by specifying the `iter` argument (e.g. `iter = 3000`).
345+
can be done by specifying the `iter` argument (e.g. `iter = 3000`). However, if all parameters have proper priors (no priors were set to `NULL`), and you used the default values
346+
for iterations (2000) and chains (4), and Rhats (explained below) are greater than 2, then increasing the number of iterations alone is unlikely to solve to the problem.
346347

347348
One way to monitor whether a chain has converged to the equilibrium distribution
348349
is to compare its behavior to other randomly initialized chains. This is the
@@ -388,6 +389,7 @@ any(summary(good_rhat)[, "Rhat"] > 1.1)
388389
Details on the computation of Rhat and some of its limitations can be found in
389390
[Stan Modeling Language User's Guide and Reference Manual](https://mc-stan.org/users/documentation/).
390391

392+
391393
### Divergent transitions
392394

393395
__Recommendation:__ increase the target acceptance rate `adapt_delta`. <br>
@@ -418,7 +420,8 @@ the slower sampling is a minor cost.
418420

419421
### Maximum treedepth exceeded
420422

421-
__Recommendation:__ increase the maximum allowed treedepth `max_treedepth`. <br>
423+
__Recommendation:__ increase the maximum allowed treedepth `max_treedepth` unless
424+
all other convergence diagnostics are ok. <br>
422425

423426
Configuring the No-U-Turn-Sampler (the variant of HMC used by Stan) involves
424427
putting a cap on the depth of the trees that it evaluates during each iteration.
@@ -427,11 +430,17 @@ maximum allowed tree depth is reached it indicates that NUTS is terminating
427430
prematurely to avoid excessively long execution time. If __rstanarm__ prints a
428431
warning about transitions exceeding the maximum treedepth you should try
429432
increasing the `max_treedepth` parameter using the optional `control` argument.
430-
For example, to increase `max_treedepth` to 20 (the default used __rstanarm__ is
431-
15) you can provide the argument `control = list(max_treedepth = 20)` to any of
433+
For example, to increase `max_treedepth` to 16 (the default used __rstanarm__ is
434+
15) you can provide the argument `control = list(max_treedepth = 16)` to any of
432435
the __rstanarm__ modeling functions. If you do not see a warning about hitting
433436
the maximum treedepth (which is rare), then you do not need to worry.
434437

438+
With the models __rstanarm__ is capable of fitting, when you get a warning about
439+
max treedepth you will typically also get warnings about other diagnostics. However,
440+
if you see a max treedepth warning but all other convergence diagnostics
441+
are fine, you can typically ignore the warning. In that case the warning
442+
likely indicates efficiency issues but not that the results are invalid to analyze.
443+
435444
# Conclusion
436445

437446
In this vignette, we have gone through the four steps of a Bayesian analysis.

0 commit comments

Comments
 (0)