gce_alligator: Alligator plot: cumulative incidence by risk group and event...

View source: R/alligator.R

gce_alligatorR Documentation

Alligator plot: cumulative incidence by risk group and event type

Description

Plots the cause-specific cumulative incidence functions (CIFs) of the event of interest and the competing event over time on a single panel, with risk groups distinguished by color and event types by line type (event of interest solid, competing event dashed). In higher-risk groups the event-of-interest CIF rises above the competing-event CIF and the curves separate like an alligator's open jaws.

The x-axis is truncated at xmax (by default the model's readout time t), with tick marks at 1-unit (e.g. 1-year) intervals. The y-axis auto-scales its cap to the smallest of 25/50/75/100% that covers the peak cumulative incidence (so low-incidence settings are not compressed), with ticks at 10% (or 5% when capped at 25%). Numbers at risk for each group are shown in an aligned panel below the plot. Gray's test across groups is attached.

Usage

gce_alligator(
  object,
  groups = 2,
  method = c("optimal", "quantile"),
  criterion = c("omegaplus", "cif"),
  xlab = "Time (years)",
  ylab = "Cumulative incidence",
  group.lab = "Risk group",
  risk.table = TRUE,
  ymax = NULL,
  xmax = NULL
)

## S3 method for class 'gce_alligator'
print(x, ...)

## S3 method for class 'gce_alligator'
plot(x, ...)

Arguments

object

a "gcemod" object from gcecox, gcefg, or gcecif.

groups

a gce_cutpoints result, a grouping factor of length n, or a single integer giving the number of risk groups (default 2). When an integer is given, the groups are derived with gce_cutpoints using method.

method

grouping rule used when groups is an integer: "optimal" (default) or "quantile" (equal-sized groups). Ignored when groups is a cutpoints object or a factor.

criterion

optimal-search criterion when groups is an integer and method = "optimal": "omegaplus" (default, log-\omega^{+} separation; not tail-sensitive) or "cif" (joint Gray statistic on the observed cumulative incidence of both events). See gce_cutpoints.

xlab, ylab

axis labels.

group.lab

legend title for the risk groups (default "Risk group").

risk.table

logical; show numbers at risk in an aligned panel below the plot (default TRUE).

ymax

optional numeric upper cap for the y-axis (0-1). If NULL (default) the cap auto-scales to 25/50/75/100% based on the peak incidence.

xmax

upper limit of the time axis; defaults to the readout time t of the fit.

x

a "gce_alligator" object.

...

unused.

Value

An object of class "gce_alligator" with print and plot methods. It is a list holding the cumulative incidence curves ($data), the numbers at risk ($n.risk), Gray's tests across groups ($grays_test), and the cutpoints. Printing shows the group sizes and Gray's tests; plot draws the figure and returns the ggplot/patchwork object invisibly. The display arguments (xlab, ylab, group.lab, risk.table, ymax) are stored and used by plot.

Examples

data(hn)
fit <- gcecox(Surv(time, status) ~ age + t_cat + p16, data = hn, t = 5)
al <- gce_alligator(fit, groups = 2)
al
plot(al)

gcemod documentation built on Dec. 1, 2026, 1:06 a.m.