diagnostics: MCMC Diagnostics for clmstan objects

View source: R/methods.R

diagnosticsR Documentation

MCMC Diagnostics for clmstan objects

Description

Provides a summary of MCMC convergence diagnostics including HMC-specific diagnostics (divergences, treedepth, E-BFMI) and general convergence measures (Rhat, ESS).

Usage

diagnostics(object, ...)

## S3 method for class 'clmstan'
diagnostics(
  object,
  detail = FALSE,
  rhat_threshold = 1.01,
  ess_threshold = 400,
  ...
)

Arguments

object

A clmstan object

...

Additional arguments (ignored)

detail

Logical. If TRUE, show full parameter-level diagnostics table. If FALSE (default), show only summary and any problematic parameters.

rhat_threshold

Threshold for flagging high Rhat values. Default 1.01.

ess_threshold

Threshold for flagging low ESS values. Default 400.

Details

The function checks for the following issues:

  • Divergences: Number of divergent transitions (ideally 0)

  • Treedepth: Transitions hitting max treedepth (efficiency issue)

  • E-BFMI: Energy Bayesian Fraction of Missing Information (values < 0.3 indicate problems)

  • Rhat: Potential scale reduction factor (values > 1.01 indicate lack of convergence)

  • ESS: Effective sample size for bulk and tail (low values indicate high autocorrelation)

Value

Invisibly returns a list containing:

  • hmc: HMC diagnostics from CmdStanMCMC$diagnostic_summary()

  • convergence: Data frame of per-parameter Rhat and ESS values

  • issues: Logical indicating whether any issues were detected

Examples

## Not run: 
fit <- clm_stan(rating ~ temp, data = wine)
diagnostics(fit)
diagnostics(fit, detail = TRUE)

## End(Not run)


clmstan documentation built on June 29, 2026, 5:06 p.m.