Learn R Programming

qbrms (version 1.0.1)

plot_parameters: Plot Parameters with Prior/Posterior Comparison

Description

Create density plots for multiple model parameters, optionally comparing posterior estimates with their priors. Returns a ggplot2 object with faceted parameter plots.

Create density plots for multiple model parameters, optionally comparing posterior estimates with their priors. Returns a ggplot2 object with faceted parameter plots.

Usage

plot_parameters(
  object,
  pars = NULL,
  show_prior = FALSE,
  ndraws = 200,
  prior_ndraws = 200,
  ncol = 2,
  alpha_levels = c(0.8, 0.5),
  colours = c("#1F78B4", "#E31A1C"),
  verbose = TRUE,
  ...
)

plot_parameters( object, pars = NULL, show_prior = FALSE, ndraws = 200, prior_ndraws = 200, ncol = 2, alpha_levels = c(0.8, 0.5), colours = c("#1F78B4", "#E31A1C"), verbose = TRUE, ... )

Value

A ggplot2 object with faceted parameter density plots.

A ggplot2 object with faceted parameter density plots.

Arguments

object

A qbrms_fit object.

pars

Optional character vector of parameter names to plot. If NULL, plots all fixed-effect parameters.

show_prior

Logical; if TRUE, overlay prior distributions.

ndraws

Number of posterior draws to use for plotting.

prior_ndraws

Number of prior draws to use if show_prior = TRUE.

ncol

Number of columns for faceting (default 2).

alpha_levels

Numeric vector of length 2 giving alpha levels for c(posterior, prior). Default c(0.8, 0.5).

colours

Character vector of length 2 giving colours for c(posterior, prior). Default c("#1F78B4", "#E31A1C").

verbose

Logical; print progress information.

...

Additional arguments (currently unused).

Examples

Run this code
if (FALSE) {
fit <- qbrms(y ~ x1 + x2, data = my_data, sample_prior = "yes")

# Plot all parameters
plot_parameters(fit)

# Plot specific parameters with priors
plot_parameters(fit, pars = c("x1", "x2"), show_prior = TRUE)

# Customize appearance
plot_parameters(fit, show_prior = TRUE) + 
  theme_bw() + 
  labs(title = "My Parameter Estimates")
}
if (FALSE) {
fit <- qbrms(y ~ x1 + x2, data = my_data, sample_prior = "yes")

# Plot all parameters
plot_parameters(fit)

# Plot specific parameters with priors
plot_parameters(fit, pars = c("x1", "x2"), show_prior = TRUE)

# Customize appearance
plot_parameters(fit, show_prior = TRUE) + 
  theme_bw() + 
  labs(title = "My Parameter Estimates")
}

Run the code above in your browser using DataLab