View source: R/plot_diagnostics.R
| plot_divergences | R Documentation |
Creates visualizations to investigate divergent transitions. Parallel coordinates and scatter plots highlight where in parameter space divergences occur.
plot_divergences(fit, pars = NULL, type = c("parcoord", "scatter"))
fit |
A |
pars |
Character vector of parameter names. If NULL, uses variance parameters. |
type |
Plot type: "parcoord" (parallel coordinates) or "scatter". |
Divergent transitions indicate regions of high posterior curvature that the sampler cannot efficiently explore. Common causes:
Very narrow funnels (hierarchical models)
Strong correlations
Multi-modality
A ggplot object or base R plot (invisible).
plot_pairs(), n_divergent()
set.seed(123)
df <- data.frame(x = rnorm(60))
df$y <- rpois(60, exp(0.5 + 0.3 * df$x))
fit <- tulpa(y ~ x, data = df, family = "poisson", mode = "hmc",
control = list(n_iter = 500L, warmup = 250L, n_chains = 2L,
seed = 1L))
plot_divergences(fit)
plot_divergences(fit, type = "scatter")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.