Whether a model fit has converged, from the Rhat and effective sample sizes of its parameters and its rate of divergent transitions.
Arguments
- fit
A
kb_fitobject.- ...
These dots are for future extensions and must be empty.
- rhat
A number giving the maximum acceptable Rhat.
- ess
A number giving the minimum acceptable bulk and tail effective sample size per chain.
- max_perc_divergent
A number giving the maximum acceptable percentage of saved draws that ended in a divergent transition.
Assessing convergence
Three conditions must be met:
every parameter's rank-normalized split Rhat below
rhat(default 1.01; Vehtari et al. 2021, Section 2);every parameter's bulk and tail effective sample size at least
esstimes the number of chains (default 100, which is 400 for four chains; Vehtari et al. 2021);the percentage of divergent transitions at or below
max_perc_divergent(default 0.2% of saved draws). Setmax_perc_divergent = 0to require none.
Rhat and the effective sample sizes are those of posterior::rhat(),
posterior::ess_bulk(), and posterior::ess_tail(), reported for each
parameter by posterior::summarise_draws(fit).
Resolving convergence failure
In order, try the following:
For Rhat or effective sample sizes that fail their thresholds, increase
nthinto run more iterations while saving the same number of draws or increasenitersfor more saved draws per chain.For divergent transitions, increase
adapt_deltathrough thecontrolargument of thekb_fit_*()functions (for example,kb_fit_*(df, control = list(adapt_delta = 0.99)); the default is 0.95). A higher value makes the sampler take smaller steps, which reduces divergent transitions at the cost of a longer runtime.If either problem persists, check the data and the fit with
pp_check()andkb_influence(): a unit mistake, outliers, or a poor fit can cause both.
References
Vehtari, A., Gelman, A., Simpson, D., Carpenter, B., and Bürkner, P.-C. (2021). Rank-normalization, folding, and localization: An improved \(\widehat{R}\) for assessing convergence of MCMC. Bayesian Analysis, 16(2), 667-718. doi:10.1214/20-BA1221
Stan Development Team. Runtime warnings and convergence problems. https://mc-stan.org/learn-stan/diagnostics-warnings.html
See also
Other diagnostics:
kb_influence(),
kb_plot_trace(),
kb_sensitivity(),
loo.kb_fit(),
pp_check.kb_fit()