calculate_diagnostics: Calculate MCMC diagnostics

View source: R/diagnostics.R

calculate_diagnosticsR Documentation

Calculate MCMC diagnostics

Description

Computes posterior summaries (mean, SD, quantiles) and effective sample sizes after discarding a burn-in fraction.

Usage

calculate_diagnostics(
  samples,
  burnin_frac = 0.2,
  param_names = NULL,
  title = ""
)

Arguments

samples

Matrix of MCMC samples (iterations x parameters).

burnin_frac

Fraction of samples to discard as burn-in.

param_names

Optional character vector of parameter names.

title

Optional title for printed output.

Value

A data frame with posterior summaries and effective sample sizes.

Examples

log_post <- function(x) dnorm(x, log = TRUE)
res <- twalk(log_post, n_iter = 2000, x0 = -2, xp0 = 2)
calculate_diagnostics(
  res$all_samples,
  burnin_frac = 0.2,
  param_names = "theta",
  title = "Standard normal"
)


Rtwalk documentation built on Feb. 5, 2026, 5:07 p.m.