plot.birp: Plot posterior distributions of rate and/or step change...

plot.birpR Documentation

Plot posterior distributions of rate and/or step change parameters

Description

Plots the posterior densities of the rate (gamma) and/or step change (Delta) parameters estimated by a birp object.

Usage

## S3 method for class 'birp'
plot(
  x,
  change = if (x$post_gamma$exists && x$post_Delta$exists) "both" else if
    (x$post_gamma$exists) "rate" else "step",
  shadingIncrease = NA,
  shadingDecrease = "#f2c7c7",
  col = "black",
  lwd = 1,
  lty = NULL,
  xlim = NA,
  ylim = NA,
  add = FALSE,
  xlab = NULL,
  ylab = "Posterior density",
  legend = NULL,
  lineAtZero = TRUE,
  ...
)

Arguments

x

A birp object.

change

Character; which parameters to plot. One of "rate", "step", or "both". Default is "both" if both exist, otherwise whichever exists.

shadingIncrease

Character or color specification; Shading color for the range where the parameter is greater than 0. If NA, shading is omitted. Default is NA.

shadingDecrease

Character or color specification; Shading color for the range where the parameter is less than 0. If NA, shading is omitted. Default is "#f2c7c7".

col

Character vector or color values; Line color(s) for the density plots. Recycled per parameter type. Default is "black".

lwd

Numeric vector; Line width(s) for the density plots. Recycled per parameter type. Default is 1.

lty

Numeric or character vector; Line type(s) for the density plots. If a single value is provided, it is recycled. Default cycles through 1:n within each parameter type.

xlim

Numeric vector of length 2; Optional x-axis limits applied to all panels. If NA, limits are determined automatically. Default is NA.

ylim

Numeric vector of length 2; Optional y-axis limits applied to all panels. If NA, limits are determined automatically. Default is NA.

add

Logical; If TRUE, adds the densities to an existing plot (only valid when change is "gamma" or "Delta"). Default is FALSE.

xlab

Character (or expression) vector of length 1 or 2; Label(s) for the x-axis. When change = "both", provide two labels (one per panel) or a single value recycled for both. Defaults to expression(gamma) / expression(Delta) as appropriate.

ylab

Character; Label for the y-axis. Default is "Posterior density".

legend

Character vector of legend labels, or NA to suppress the legend. Defaults to the names stored in the respective post_* object.

lineAtZero

Logical; If TRUE, adds a vertical line at x = 0. Default is TRUE.

...

Additional graphical parameters passed to lines and plot.

Value

No return value, called for side effects.

See Also

birp

Examples

data <- simulate_birp(timepoints = 1:5)
est <- birp(data, change = "both")
plot(est)
plot(est, change = "rate")
plot(est, change = "step")

birp documentation built on Nov. 3, 2026, 1:09 a.m.