Learn R Programming

clmstan (version 0.1.1)

diagnostics: 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 clmstan diagnostics( object, detail = FALSE, rhat_threshold = 1.01, ess_threshold = 400, ... )

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

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)

Examples

Run this code
if (FALSE) {
fit <- clm_stan(rating ~ temp, data = wine)
diagnostics(fit)
diagnostics(fit, detail = TRUE)
}

Run the code above in your browser using DataLab