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
#> 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