Add single row to survival definitions

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

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

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
#> varname formula scale shape #> 1: survTime 1.5*x1 grp*50 + (1-grp)*25 grp*1 + (1-grp)*1.5 #> 2: censorTime 0 80 1
# Baseline data definitions dtSurv <- genData(300, def) # Add survival times dtSurv <- genSurv(dtSurv, sdef) head(dtSurv)
#> id x1 x2 grp survTime censorTime #> 1: 1 1 0 1 8.608 21.564 #> 2: 2 1 1 0 0.692 46.502 #> 3: 3 0 1 1 98.678 132.305 #> 4: 4 0 1 0 210.815 23.778 #> 5: 5 1 0 1 8.831 20.523 #> 6: 6 0 1 0 62.965 107.078