Visualizes posterior density distributions for selected parameters, allowing easy comparison between multiple models (e.g., Default vs. Custom priors) or inspection of a single model.
Usage
plot_posterior(
models,
parameter,
col = NULL,
lwd = 2,
legend_pos = "topleft",
density_args = list(),
...
)Arguments
- models
A
becauseobject or a named list ofbecauseobjects. If a list is provided, the names are used for the legend. Example:list("Default" = fit1, "Custom" = fit2).- parameter
Character string. A regular expression or exact name of the parameter(s) to plot. Example:
"beta","^alpha","beta_Y_X". Plots all matching parameters.- col
Optional vector of colors. Defaults to a standard palette (black, blue, red, etc.).
- lwd
Line width (default = 2).
- legend_pos
Legend position (default = "topleft"). Set to
NULLto suppress.- density_args
List of additional arguments passed to
stats::density(). Useful for handling boundary corrections (e.g.,list(from=0)for truncated priors).- ...
Additional arguments passed to
plot().
