Add single row to survival definitions
defSurv(
dtDefs = NULL,
varname,
formula = 0,
scale = 1,
shape = 1,
transition = 0
)
Definition data.table to be modified
Variable name
Covariates predicting survival
Scale parameter for the Weibull distribution.
The shape of the Weibull distribution. Shape = 1 for an exponential distribution
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".
A data.table named dtName that is an updated data definitions table
# 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
#> varname formula scale shape transition
#> <char> <char> <char> <char> <num>
#> 1: survTime 1.5*x1 grp*50 + (1-grp)*25 grp*1 + (1-grp)*1.5 0
#> 2: censorTime 0 80 1 0
# Baseline data definitions
dtSurv <- genData(300, def)
# Add survival times
dtSurv <- genSurv(dtSurv, sdef)
head(dtSurv)
#> Key: <id>
#> id x1 x2 grp survTime censorTime
#> <int> <int> <int> <int> <num> <num>
#> 1: 1 1 1 1 6.763 42.435
#> 2: 2 0 1 0 7.461 40.865
#> 3: 3 1 0 1 6.822 79.030
#> 4: 4 0 1 0 117.528 13.109
#> 5: 5 1 0 1 0.853 202.085
#> 6: 6 1 0 1 20.644 48.074