rhat_summary: Summarize MCMC R-hat Values

View source: R/rhat_summary.R

rhat_summaryR Documentation

Summarize MCMC R-hat Values

Description

Extract R-hat values from a fitted MCMC object as a numeric vector. The returned object prints a compact convergence summary and can be passed directly to functions such as hist.

Usage

rhat_summary(fit, ...)

## Default S3 method:
rhat_summary(fit, ...)

## S3 method for class 'mcmc_fit'
rhat_summary(
  fit,
  pars = NULL,
  chains = NULL,
  best_chains = NULL,
  inc_random = FALSE,
  inc_transform = TRUE,
  inc_generate = FALSE,
  finite = TRUE,
  ...
)

Arguments

fit

A fitted model object.

...

Additional arguments passed to methods.

pars

Character or numeric vector specifying parameters to include. If NULL, all available parameters are summarized.

chains

Numeric vector specifying chains to include.

best_chains

Integer; number of best chains to retain based on mean log-posterior.

inc_random

Logical; whether to include random effects. Default is FALSE.

inc_transform

Logical; whether to include transformed parameters. Default is TRUE.

inc_generate

Logical; whether to include generated quantities. Default is FALSE.

finite

Logical; whether to drop non-finite or missing R-hat values. Default is TRUE.

Value

A numeric vector of R-hat values with class "rhat_summary".

Examples


  data(debate, package = "BayesRTMB")
  mdl <- rtmb_lm(sat ~ talk + perf, data = debate)
  fit <- mdl$sample(sampling = 200, warmup = 200, chains = 2)
  r <- rhat_summary(fit)
  r
  hist(r)


BayesRTMB documentation built on Nov. 24, 2026, 9:06 a.m.