Learn R Programming

FBMS (version 1.4)

diagn_plot: Plot Convergence Diagnostics for GMJMCMC or GMJMCMC Merged Results

Description

Plots the convergence of summary statistics (e.g., median, mean) of log posteriors or marginal likelihoods over populations for a GMJMCMC or GMJMCMC merged result object, with support for various plot types.

Usage

diagn_plot(
  res,
  FUN = median,
  conf = 0.95,
  burnin = 0,
  window = 5,
  ylim = NULL,
  type = "convergence",
  per_thread = FALSE,
  pool = FALSE,
  mass = FALSE,
  ...
)

Value

Returns a list of summary statistics used for the plot.

Arguments

res

Object of class gmjmcmc or gmjmcmc_merged containing results from a GMJMCMC run or merged runs.

FUN

Function to compute summary statistics (e.g., median, mean). Default is median.

conf

Numeric; confidence level for intervals (e.g., 0.95 for 95%). Default is 0.95.

burnin

Integer; number of initial populations to skip. Default is 0.

window

Integer; size of the sliding window for computing standard deviation. Default is 5.

ylim

Numeric vector; y-axis limits for the plot. If NULL, computed from the data being plotted.

type

String; type of plot to produce. Options are:

  • "convergence": (Default) Summary statistic with confidence intervals based on sliding window SD.

  • "min-mean-max": Min, mean, and max log-posteriors per population across threads.

  • "all-threads": Each thread's summary statistic (defined by FUN) as a separate time series.

  • "total-mass": Total log-posterior (sum of log-posteriors of all unique models) per population.

per_thread

Logical; if TRUE and type = "total-mass", plots mass for each thread individually.

pool

Logical; if TRUE, statistics are calculated across all models pooled from all threads for each population.

mass

Logical; if TRUE, total statistics are calculated for each thread under "min-mean-max" settings.

...

Additional graphical parameters passed to plot and lines (e.g., col, lwd, lty, main, xlab, ylab).

Examples

Run this code
data(exoplanet)
result <- fbms(semimajoraxis ~ ., data = exoplanet, method = "gmjmcmc", transforms = c("sin"))
diagn_plot(result, FUN = median, conf = 0.95, main = "Convergence Plot")

Run the code above in your browser using DataLab