Add single row to survival definitions

defSurv(
  dtDefs = NULL,
  varname,
  formula = 0,
  scale = 1,
  shape = 1,
  transition = 0
)

Arguments

dtDefs

Definition data.table to be modified

varname

Variable name

formula

Covariates predicting survival

scale

Scale parameter for the Weibull distribution.

shape

The shape of the Weibull distribution. Shape = 1 for an exponential distribution

transition

An integer value indicating the starting point for a new specification of the hazard function. It will default to 0 (and must be 0) for the first instance of a "varname".

Value

A data.table named dtName that is an updated data definitions table

Examples

# Baseline data definitions

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

# Survival data definitions

sdef <- defSurv(
  varname = "survTime", formula = "1.5*x1",
  scale = "grp*50 + (1-grp)*25", shape = "grp*1 + (1-grp)*1.5"
)

sdef <- defSurv(sdef, varname = "censorTime", scale = 80, shape = 1)

sdef
#> Key: <varname>
#>       varname formula               scale               shape transition
#>        <char>  <char>              <char>              <char>      <num>
#> 1: censorTime       0                  80                   1          0
#> 2:   survTime  1.5*x1 grp*50 + (1-grp)*25 grp*1 + (1-grp)*1.5          0

# Baseline data definitions

dtSurv <- genData(300, def)

# Add survival times

dtSurv <- genSurv(dtSurv, sdef)

head(dtSurv)
#> Key: <id>
#>       id    x1    x2   grp censorTime survTime
#>    <int> <int> <int> <int>      <num>    <num>
#> 1:     1     1     0     1     61.724    3.007
#> 2:     2     1     1     0     11.215    5.839
#> 3:     3     0     1     1    157.884   82.691
#> 4:     4     0     1     0    113.349   20.255
#> 5:     5     1     0     1     63.325    2.862
#> 6:     6     0     1     0     50.646  193.565