Skip to contents

Creates visualizations to investigate divergent transitions. Parallel coordinates and scatter plots highlight where in parameter space divergences occur.

Usage

plot_divergences(fit, pars = NULL, type = c("parcoord", "scatter"))

Arguments

fit

A ratiod_fit object (HMC backend).

pars

Character vector of parameter names. If NULL, uses variance parameters.

type

Plot type: "parcoord" (parallel coordinates) or "scatter".

Value

A ggplot object or base R plot (invisible).

Details

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

Examples

# \donttest{
sim <- sim_ratiod(n = 100, family = ratiod_poisson_gamma(), seed = 1)
fit <- tratio(y_num | y_denom ~ x1 + (1 | group), data = sim$data,
              family = ratiod_poisson_gamma(),
              control = list(iter = 1000, chains = 2, seed = 1))
n_divergent(fit)
#> [1] 0
plot_divergences(fit)
#> No divergent transitions to plot
# }