Skip to contents

Generates trace plots for specified parameters from a fitted Stan model contained within a bipod object. These plots visualize the sampled values of parameters across MCMC iterations for each chain, helping to assess convergence.

Usage

plot_traces(x, fit, pars = c(), diagnose = FALSE)

Arguments

x

A bipod object that contains at least one fitted Stan model. It must include the metadata and parameters related to the MCMC sampling process.

fit

The fit object within the bipod object, containing the MCMC results, including draws for parameters.

pars

A character vector specifying the names of the parameters to plot. If empty, all available parameters will be plotted.

diagnose

A logical value indicating whether to color the plots based on convergence diagnostics. If TRUE, the plots will include color coding based on the R-hat convergence statistic, with red indicating problematic parameters (R-hat > 1.01). (default is FALSE)

Value

A ggplot2 object displaying the trace plots for the specified parameters. The plot includes lines for each chain, with optional color coding based on convergence.