Skip to contents

Generates density plots for the posterior distributions of multiple parameters from a fitted model within a bipod object. This function can optionally overlay histograms of the posterior samples on top of the density plots for a better visual comparison of the distribution. This is useful when you want to examine the posterior distributions of several parameters simultaneously.

Usage

plot_posteriors(
  x,
  x_fit,
  par_list,
  with_histogram = F,
  alpha = 0.6,
  colors = NULL
)

Arguments

x

A bipod object of class bipod. It must contain a 'fit' field with the fitted model and associated results. This object should have undergone model selection and fitting.

x_fit

The fit object within x that contains the desired parameters. It holds the fitted values for the parameters to be plotted.

par_list

A character vector containing the names of the parameters whose posterior distributions are to be plotted. These should match the parameter names available in the model fit.

with_histogram

A logical value indicating whether to overlay histograms on the density plots. If TRUE, histograms will be displayed alongside the density plots to give a clearer visualization of the sample distribution. The default is FALSE.

alpha

A numeric value between 0 and 1 specifying the transparency level of the density plots. A lower value (e.g., 0.2) will make the density plot more transparent, while a higher value (e.g., 0.8) will make it more opaque. The default is 0.6.

colors

A character vector specifying the colors to use for the density plots of each parameter. If NULL (default), a predefined color scheme will be used. The length of this vector should match the number of parameters in par_list.

Value

A ggplot2 object displaying the density plots of the specified parameters. If with_histogram is TRUE, histograms will be overlaid on the density plots.