Generate Posterior Density Plots by Species Complex
plot_density.RdThis function creates posterior density plots for the hierarchical Bayesian model parameters aggregated by species complex. It uses the stanfit object and associated data generated by `run_stan()`. The plot can optionally be saved to a specified directory.
Arguments
- stan_results
Named list output from `run_stan()` containing the fitted model and related data.
- unlabel
Logical. If TRUE, removes labels from the plot. Default is FALSE.
- complex_names
Optional character vector. Names of species complexes to include in the plot. If NULL, all are included.
- plot_dir
Optional character. Directory path to save the plot image. If NULL, the plot is not saved.