Learn R Programming

mets (version 1.3.11)

sim_recurrent: Simulate recurrent events with a single event type and a terminal event

Description

A convenience wrapper around sim_recurrentII for the common case of a single recurrent event type. Frailty and censoring options are passed through to sim_recurrent_list.

Usage

sim_recurrent(
  n,
  cumhaz,
  death.cumhaz = NULL,
  r1 = NULL,
  rd = NULL,
  rc = NULL,
  ...
)

Arguments

n

Number of subjects to simulate.

cumhaz

Two-column matrix (time, cumhaz) giving the cumulative hazard of the recurrent event.

death.cumhaz

Two-column matrix (time, cumhaz) giving the cumulative hazard of the terminal event. If NULL, no terminal event is included.

r1

Optional numeric vector of length n of subject-specific relative risks for the recurrent event.

rd

Optional numeric vector of length n of subject-specific relative risks for the terminal event.

rc

Optional numeric vector of length n of subject-specific multipliers for the exponential censoring rate.

...

Further arguments passed to sim_recurrent_list, including dependence, var.z, gap.time, and max.recurrent.

Author

Thomas Scheike

Examples

Run this code
data(CPH_HPN_CRBSI)
dr    <- CPH_HPN_CRBSI$terminal
base1 <- CPH_HPN_CRBSI$crbsi
base4 <- CPH_HPN_CRBSI$mechanical

## Single recurrent event type, with and without terminal event
rr <- sim_recurrent(5, base1)
dlist(rr, . ~ id, n = 0)

rr <- sim_recurrent(5, base1, death.cumhaz = dr)
dlist(rr, . ~ id, n = 0)

## Verify that estimated rates recover the true baselines (increase n for precision)
rr <- sim_recurrent(100, base1, death.cumhaz = dr)
par(mfrow = c(1, 3))
mets:::showfitsim(causes = 1, rr, dr, base1, base1)

## Shared frailty across all processes
rr <- sim_recurrent(100, base1, death.cumhaz = dr, dependence = 1, var.z = 0.4)
dtable(rr, ~death + status)

## Two event types; second type uses the mechanical complication rate
set.seed(100)
rr <- sim_recurrentII(100, base1, base4, death.cumhaz = dr)
dtable(rr, ~death + status)
par(mfrow = c(2, 2))
mets:::showfitsim(causes = 2, rr, dr, base1, base4)

## Three event types and two causes of death via sim_recurrent_list
set.seed(100)
cumhaz <- list(base1, base1, base4)
drl    <- list(dr, base4)
rr     <- sim_recurrent_list(100, cumhaz, death.cumhaz = drl, dependence = 0)
dtable(rr, ~death + status)
mets:::showfitsimList(rr, cumhaz, drl)

Run the code above in your browser using DataLab