Generating single competing risk survival variable

addCompRisk(
  dtName,
  events,
  timeName,
  censorName = NULL,
  eventName = "event",
  typeName = "type",
  keepEvents = FALSE,
  idName = "id"
)

Arguments

dtName

Name of complete data set to be updated

events

Vector of column names that include time-to-event outcome measures

timeName

A string to indicate the name of the combined competing risk time-to-event outcome that reflects the minimum observed value of all time-to-event outcomes.

censorName

The name of a time-to-event variable that is the censoring variable. Must be one of the "events" names. Defaults to NULL.

eventName

The name of the new numeric/integer column representing the competing event outcomes. If censorName is specified, the integer value for that event will be 0. Defaults to "event", but will be ignored if timeName is NULL.

typeName

The name of the new character column that will indicate the event type. The type will be the unique variable names in survDefs. Defaults to "type", but will be ignored if timeName is NULL.

keepEvents

Indicator to retain original "events" columns. Defaults to FALSE.

idName

Name of id field in existing data set.

Value

An updated data table

Examples

d1 <- defData(varname = "x1", formula = .5, dist = "binary")
d1 <- defData(d1, "x2", .5, dist = "binary")

dS <- defSurv(varname = "reinc", formula = "-10 - 0.6*x1 + 0.4*x2", shape = 0.3)
dS <- defSurv(dS, "death", "-6.5 + 0.3*x1 - 0.5*x2", shape = 0.5)
dS <- defSurv(dS, "censor", "-7", shape = 0.55)

dd <- genData(10, d1)
dd <- genSurv(dd, dS)

addCompRisk(dd, c("reinc","death", "censor"), timeName = "time",
   censorName = "censor", keepEvents = FALSE)
#> Key: <id>
#> Index: <type>
#>        id    x1    x2   time event   type
#>     <int> <int> <int>  <num> <num> <char>
#>  1:     1     1     0 18.968     0 censor
#>  2:     2     0     0 16.409     1  reinc
#>  3:     3     1     0 26.264     1  reinc
#>  4:     4     1     1 22.737     1  reinc
#>  5:     5     0     0 18.305     1  reinc
#>  6:     6     1     1 10.122     1  reinc
#>  7:     7     1     0  9.404     0 censor
#>  8:     8     1     1 21.707     2  death
#>  9:     9     1     0  8.717     2  death
#> 10:    10     0     0 25.203     2  death