Learn R Programming

topolow (version 1.0.0)

create_diagnostic_plots: Create Diagnostic Plots for Multiple Chains

Description

Creates trace and density plots for multiple Adaptive Monte Carlo Sampling or optimization chains to assess convergence and mixing. Displays parameter trajectories and distributions across chains.

Usage

create_diagnostic_plots(
  chain_files,
  mutual_size = 2000,
  output_file = "diagnostic_plots.png",
  output_dir,
  save_plot = FALSE,
  width = 3000,
  height = 3000,
  res = 300
)

Value

A ggplot object of the combined plots.

Arguments

chain_files

Character vector of paths to CSV files containing chain data

mutual_size

Integer number of samples to use from end of each chain

output_file

Character path for saving plot. Required if save_plot is TRUE.

output_dir

Character. Directory for output files. Required if save_plot is TRUE.

save_plot

Logical. Whether to save plots to files. Default: FALSE

width, height, res

Plot dimensions and resolution for saving

Examples

Run this code
# This example uses sample data files included with the package.
chain_files <- c(
  system.file("extdata", "diag_chain1.csv", package = "topolow"),
  system.file("extdata", "diag_chain2.csv", package = "topolow"),
  system.file("extdata", "diag_chain3.csv", package = "topolow")
)

# Only run the example if the files are found
if (all(nzchar(chain_files))) {
  # Create diagnostic plot without saving to a file
  create_diagnostic_plots(chain_files, mutual_size = 2, save_plot = FALSE)
}

Run the code above in your browser using DataLab