defSurv {simstudy} | R Documentation |
Add single row to survival definitions
Description
Add single row to survival definitions
Usage
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
# Baseline data definitions
dtSurv <- genData(300, def)
# Add survival times
dtSurv <- genSurv(dtSurv, sdef)
head(dtSurv)
[Package simstudy version 0.8.1 Index]