ciplot: 'cuminc2' plotting method

View source: R/plot.R

ciplotR Documentation

cuminc2 plotting method

Description

Plot a cuminc2 object with optional cumulative events or estimate table, Gray's test results, and other features.

Usage

ciplot(
  x,
  col.ci = seq_along(xx),
  lty.ci = par("lty"),
  lwd.ci = par("lwd"),
  events = TRUE,
  atrisk = TRUE,
  events.total = TRUE,
  wh.events = c("events", "est", "est.sd", "est.ci", "atrisk", "percent", "percent.ci"),
  events.lab = NULL,
  events.pad = 0.5,
  events.digits = ifelse(grepl("percent", wh.events), 0L, 3L),
  events.lines = TRUE,
  events.col = FALSE,
  include_censored = FALSE,
  main = NULL,
  xlab = "Time",
  ylab = "Probability",
  groups.lab = names(xx),
  xlim = NULL,
  ylim = NULL,
  cex.lab = par("cex.lab"),
  cex.main = par("cex.main"),
  cex.axis = par("cex.axis"),
  cex.events = cex.axis,
  gy_test = TRUE,
  test_details = TRUE,
  legend.args = list(),
  split = FALSE,
  xaxis.at = pretty(xlim),
  yaxis.at = pretty(ylim),
  xaxis.lab = xaxis.at,
  yaxis.lab = yaxis.at,
  events.at = xaxis.at,
  groups.order = seq_along(xx),
  extra.margin = 5L,
  mar = NULL,
  add = FALSE,
  panel.first = NULL,
  panel.last = NULL,
  ...
)

## S3 method for class 'cuminc2'
plot(
  x,
  col.ci = seq_along(xx),
  lty.ci = par("lty"),
  lwd.ci = par("lwd"),
  events = TRUE,
  atrisk = TRUE,
  events.total = TRUE,
  wh.events = c("events", "est", "est.sd", "est.ci", "atrisk", "percent", "percent.ci"),
  events.lab = NULL,
  events.pad = 0.5,
  events.digits = ifelse(grepl("percent", wh.events), 0L, 3L),
  events.lines = TRUE,
  events.col = FALSE,
  include_censored = FALSE,
  main = NULL,
  xlab = "Time",
  ylab = "Probability",
  groups.lab = names(xx),
  xlim = NULL,
  ylim = NULL,
  cex.lab = par("cex.lab"),
  cex.main = par("cex.main"),
  cex.axis = par("cex.axis"),
  cex.events = cex.axis,
  gy_test = TRUE,
  test_details = TRUE,
  legend.args = list(),
  split = FALSE,
  xaxis.at = pretty(xlim),
  yaxis.at = pretty(ylim),
  xaxis.lab = xaxis.at,
  yaxis.lab = yaxis.at,
  events.at = xaxis.at,
  groups.order = seq_along(xx),
  extra.margin = 5L,
  mar = NULL,
  add = FALSE,
  panel.first = NULL,
  panel.last = NULL,
  ...
)

Arguments

x

an object of class cuminc2

col.ci, lty.ci, lwd.ci

line color, type, and width for each curve

events

logical; if TRUE, a cumulative events table is drawn

atrisk

logical; if TRUE, the number at risk is added to the events table

events.total

logical or numeric; if TRUE, cumulative events for each group is added to events table at a calculated position; for more control, use a specific x-coordinate

wh.events

a character string giving the type of events table to show; one of "events" (cumulative number of events), "est" (estimates, see timepoints), "est.sd" (estimate +/- standard deviation), "est.ci" (estimate with confidence interval), "atrisk" (event at-risk table with censored), "percent" (percent), or "percent.ci" (pecent with confidence interval)

events.lab

heading for events table

events.pad

extra padding between plot and events table; alternatively, a vector of padding for each line in the events table, recycled as needed

events.digits

when estimates are shown in events table (see wh.events), number of digits past the decimal to show

events.lines

logical; draw lines next to groups in events table

events.col

logical or a vector with colors for events table text; if TRUE, col.ci will be used

include_censored

logical; if TRUE, censored patients are included in at-risk counts (may not be desired); the default (FALSE) will only sum the at-risk table rows

main

title of plot

xlab, ylab

x- and y-axis labels

groups.lab

labels for each line in events table

xlim, ylim

x- and y-axis limits

cex.lab, cex.main

text size for axis and main titles

cex.axis

text size for axis labels and gy_testevents table

cex.events

text size for events table

gy_test

logical; if TRUE the tests of group equality will be shown

test_details

logical; if TRUE (default), all test details (test statistic, degrees of freedom, p-value) are shown; if FALSE, only the p-value is shown

legend.args

an optional named list of legend arguments controlling the annotations when gy_test = TRUE

split

optionally split plot by unique competing risks or group; one of FALSE (default, no splitting), "group", or "event"

xaxis.at, yaxis.at

positions for x- and y-axis labels and ticks

xaxis.lab, yaxis.lab

x- and y-axis tick labels

events.at

x-coordinates to show events table (default is xaxis.at)

groups.order

order of groups in events table

extra.margin

increase left margin when groups labels in events table are long (note that this will be overridden by mar)

mar

margins; see mar section in par

add

logical; if TRUE, pars are not reset; allows for multiple panels, e.g., when using par(mfrow = c(1, 2))

panel.first

an expression to be evaluated after the plot axes are set up but before any plotting takes place

panel.last

an expression to be evaluated after plotting but before returning from the function

...

additional parameters (font, mfrow, bty, tcl, cex.lab, xaxs, etc) passed to par

See Also

ciplot_by; cuminc2; summary.cuminc2; cuminc

Examples

tp <- within(transplant, {
  futime <- futime + 1e-8
  age50 <- factor(+(age > 50))
  age_cat <- cut(age, c(0, 40, 60, Inf), c('<40', '40-60', '60+'))
})

ci1 <- cuminc2(Surv(futime, event(censored)) ~ age_cat, tp)
plot(ci1)
plot(ci1, split = 'event')
plot(ci1, split = 'event', events = FALSE, test_details = FALSE,
     legend.args = list(x = 'topright', cex = 1.5, text.col = 2,
                        title = "Gray\'s test p-value for"))

## also plots "cuminc" objects but without extra features
plot(ci1$cuminc)

ci1 <- cuminc2(Surv(futime, event(censored) == death) ~ age50, tp)
plot(ci1, lty.ci = c(1, 1, 2, 2, 3, 3), col.ci = 1:2)

ci2 <- cuminc2(Surv(futime, event(censored) == death) ~ 1, tp)
plot(ci2, wh.events = 'est', events.digits = 2, groups.order = c(2, 1, 3))


raredd/cmprsk2 documentation built on March 29, 2024, 5:34 a.m.