View source: R/plot_diagnostics.R
| plot_diagnostics | R Documentation |
Visual diagnostic tools for MCMC convergence assessment. All functions provide base R fallbacks when ggplot2/bayesplot are unavailable.
Creates a combined diagnostic figure with Rhat, ESS, trace plot, and
energy/ACF panels. Requires the patchwork package for layout.
plot_diagnostics(fit, pars = NULL)
fit |
A |
pars |
Character vector of parameter names for trace plot. If NULL, uses the parameter with worst Rhat. |
Creates a 2x2 grid:
Top left: Rhat plot
Top right: ESS plot
Bottom left: Trace for worst parameter
Bottom right: Energy (HMC) or ACF (other)
A combined plot (ggplot + patchwork) or NULL if requirements not met.
diagnostic_summary(), plot_rhat(), plot_ess()
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_diagnostics(fit)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.