Learn R Programming

Rtwalk (version 2.0.1)

calculate_diagnostics: 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 = ""
)

Value

A data frame with posterior summaries and effective sample sizes.

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.

Examples

Run this code
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"
)

Run the code above in your browser using DataLab