reReg
In this vignette, we demonstrate how to create event plots and mean cumulative function in reReg
package. We will illustrate the usage of our functions with the readmission
data from the frailtypack
package (Rondeau, Mazroui, and González 2012), (González et al. 2005). The data contains re-hospitalization times after surgery in patients diagnosed with colorectal cancer. In this data set, the recurrent event is the readmission and the terminal event is either death or end of study. See ?readmission
for data details.
> library(reReg)
> packageVersion("reReg")
[1] '1.4.5'
> data(readmission, package = "frailtypack")
> head(readmission)
id enum t.start t.stop time event chemo sex dukes charlson death
1 1 1 0 24 24 1 Treated Female D 3 0
2 1 2 24 457 433 1 Treated Female D 0 0
3 1 3 457 1037 580 0 Treated Female D 0 0
4 2 1 0 489 489 1 NonTreated Male C 0 0
5 2 2 489 1182 693 0 NonTreated Male C 0 0
6 3 1 0 15 15 1 NonTreated Male C 3 0
For illustration, we first remove subjects who has more than one terminal events.
> readmission <- subset(readmission, !(id %in% c(60, 109, 280)))
An easy way to glance at recurrent event data is by plotting the event plots. Event plots can be created by applying the generic function plot()
to Recur
objects directly, as shown in Figure 1.
> reObj <- with(readmission, Recur(t.stop, id, event, death))
> plot(reObj)
Figure 1: Creating an event plot from a Recur
object.
The gray horizontal lines represent each subjects’ follow-up times, the green dots marks the recurrent events, and the red triangles marks terminal events. With the default setting, the event plot is arranged so that subjects with longer follow-up times are presented on the top. The plot()
method returns a ggplot2
object (Wickham 2009) to allow extensive flexibility and customization. Common graphical options like xlab
, ylab
, main
, and more can be directly passed down to plot()
.
> plot(reObj, cex = 1.5, xlab = "Time in days", ylab = "Patients",
+ main = "Event plot for readmission data",
+ terminal.name = "Death",
+ recurrent.name = "Hospital readmission")