Learn R Programming

PosiR (version 0.1.2)

plot.simultaneous_ci_result: Plot Simultaneous Confidence Intervals

Description

Visualizes confidence intervals returned by simultaneous_ci() using base R graphics. Estimates are shown as points with corresponding CI segments, grouped and labeled by model and coefficient name. Supports customization for log scale, character sizes, label trimming, and reference lines.

Usage

# S3 method for simultaneous_ci_result
plot(
  x,
  y = NULL,
  subset_pars = NULL,
  log.scale = FALSE,
  cex = 0.8,
  cex.labels = 0.8,
  las.labels = 1,
  pch = 16,
  col.estimate = "blue",
  col.ci = "darkgray",
  col.ref = "red",
  ref.line.pos = 0,
  lty.ref = 2,
  main = "Simultaneous Confidence Intervals",
  xlab = NULL,
  label.trim = NULL,
  ...
)

Value

Invisibly returns a list:

  • ycoords: Named vector of y-axis positions for each label

  • xlim: Range of x-axis limits used

  • ylim: Range of y-axis limits used

If no valid intervals are available for plotting, returns invisible(NULL).

Arguments

x

An object of class simultaneous_ci_result, typically returned by simultaneous_ci().

y

Ignored.

subset_pars

Optional character vector. Coefficient names to subset the plot. Default: all.

log.scale

Logical. Plot on logarithmic scale. Intervals crossing 0 or with nonpositive bounds are excluded.

cex

Point size for estimates. Default = 0.8.

cex.labels

Label size for y-axis. Default = 0.8.

las.labels

Orientation of y-axis labels (0, 1, 2, or 3). Default = 1.

pch

Plot character for point estimates. Default = 16.

col.estimate

Color of point estimates. Default = "blue".

col.ci

Color of confidence interval lines. Default = "darkgray".

col.ref

Color of reference line(s). Default = "red".

ref.line.pos

Position(s) for vertical reference line(s). Default = 0. Set to NULL to omit.

lty.ref

Line type for reference lines. Default = 2 (dashed).

main

Plot title. Default = "Simultaneous Confidence Intervals".

xlab

X-axis label. If NULL and log.scale = TRUE, label defaults to "Log Estimate".

label.trim

Integer. Trims long coefficient labels to this width (adds "..."). Optional.

...

Additional arguments passed for future use (currently ignored).

Examples

Run this code
set.seed(1)
X <- matrix(rnorm(100*2), 100, 2, dimnames = list(NULL, c("X1", "X2")))
y <- 1 + X[,1] - X[,2] + rnorm(100)
res <- simultaneous_ci(X, y, list(mod = 1:3), B = 100, add_intercept = TRUE)
plot(res)

Run the code above in your browser using DataLab