Learn R Programming

qbrms (version 1.0.1)

density_plot: Density Plot for qbrms Models

Description

Create density plots of posterior distributions with optional prior and observed-data overlays. Returns a ggplot2 object that can be modified with standard ggplot2 syntax.

Usage

density_plot(
  object,
  parameter = NULL,
  show_prior = FALSE,
  show_data = FALSE,
  ndraws = 100,
  prior_ndraws = 100,
  alpha_levels = list(posterior = 0.8, prior = 0.6, data = 1),
  colours = list(posterior = "#1F78B4", prior = "#E31A1C", data = "#000000"),
  seed = NULL,
  verbose = TRUE
)

Value

A ggplot2 object.

Arguments

object

A qbrms_fit object.

parameter

Parameter name to plot. If NULL, plots the response distribution.

show_prior

Logical; if TRUE, overlay the prior density.

show_data

Logical; if TRUE, overlay the observed data density.

ndraws

Number of posterior draws to use (default 100).

prior_ndraws

Number of prior draws to use (default 100).

alpha_levels

Named list controlling transparency for layers.

colours

Named list of colours for layers.

seed

Optional random seed.

verbose

Logical; print progress messages.