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)
#>     id x1 x2   time event  type
#>  1:  1  0  1 11.054     1 death
#>  2:  2  0  1 19.206     1 death
#>  3:  3  1  0 10.073     1 death
#>  4:  4  0  0 10.981     1 death
#>  5:  5  1  0  7.322     1 death
#>  6:  6  1  1 20.927     1 death
#>  7:  7  0  0  8.854     0 reinc
#>  8:  8  1  0 10.202     1 death
#>  9:  9  0  1 20.108     1 death
#> 10: 10  0  0 17.486     0 reinc