Learn R Programming

reReg (version 1.2.1)

plot.Recur: Produce Event Plot or Cumulative Sample Mean Function Plot

Description

Plot whether the event plot or the cumulative sample mean (CSM) function for an Recur object.

Usage

# S3 method for Recur
plot(x, CSM = FALSE, event.result = c("increasing",
  "decreasing", "asis"), csm.adjrisk = TRUE, csm.smooth = FALSE,
  control = list(), ...)

Arguments

x

an object of class Recur returned by the Recur() function.

CSM

an optional logical value indicating whether the cumulative sample mean (CSM) function will be plotted instead of the event plot (default).

event.result

an optional character string that is passed to the plotEvents() function as result, e.g., see plotEvents. This argument is used to specify whether the event plot is sorted by the subjects' terminal time. The available options are

increasing

sort the terminal time from in increasing order (default). This places longer terminal times on top.

decreasing

sort the terminal time from in decreasing order (default). This places shorter terminal times on top.

asis

present the as is, without sorting.

csm.adjrisk

an optional logical value that is passed to the plotCSM() function as adjrisk, e.g., see plotCSM. This argument indicates whether risk set will be adjusted, e.g., if TRUE, subjects leave the risk set after terminal times.

csm.smooth

an optional logical value that is passed to the plotCSM() function as smooth, e.g., see plotCSM. This argument indicates whether to add a smooth curve obtained from a monotone increasing P-splines implemented in package scam.

control

a list of control parameters. See Details.

...

graphical parameters to be passed to methods. These include xlab, ylab, main, and more. See Details.

Value

A ggplot object.

Details

The argument control consists of options with argument defaults to a list with the following values:

xlab

customizable x-label, default value is "Time".

ylab

customizable y-label, default value is "Subject" for event plot and "Cumulative mean" for CSM plot.

main

customizable title, the default value is "Recurrent event plot" when CSM = FALSE and "Sample cumulative mean function plot" when CSM = TRUE.

terminal.name

customizable label for terminal event, default value is "Terminal event".

recurrent.name

customizable legend title for recurrent event, default value is "Recurrent events".

recurrent.types

customizable label for recurrent event type, default value is NULL.

alpha

between 0 and 1, controls the transparency of points.

The xlab, ylab and main parameters can also be passed down without specifying a control list. See Examples.

See Also

Recur

Examples

Run this code
# NOT RUN {
data(simDat)
reObj <- with(simDat, Recur(Time, id, event, status))

## Event plots:
plot(reObj)
plot(reObj, event.result = "decreasing")
plot(reObj, event.result = "asis")
plot(reObj, control = list(xlab = "User xlab", ylab = "User ylab", main = "User title"))

## CSM plots
plot(reObj, CSM = TRUE)
plot(reObj, CSM = TRUE, csm.adjrisk = FALSE)
plot(reObj, CSM = TRUE, csm.smooth = TRUE)
plot(reObj, CSM = TRUE, control = list(xlab = "User xlab", ylab = "User ylab", main = "User title"))

## With (hypothetical) multiple event types
set.seed(1)
reObj2 <- with(simDat, Recur(Time, id, event * sample(1:3, nrow(simDat), TRUE), status))
plot(reObj2)
plot(reObj2, event.result = "decreasing")
plot(reObj2, event.result = "asis")

plot(reObj2, CSM = TRUE)
plot(reObj2, CSM = TRUE, csm.adjrisk = FALSE)
plot(reObj2, CSM = TRUE, csm.smooth = TRUE)

# }

Run the code above in your browser using DataLab