defSurv: Add single row to survival definitions

Description Usage Arguments Value Examples

View source: R/defSurv.R

Description

Add single row to survival definitions

Usage

1
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# 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)

kgoldfeld/simstudy documentation built on Nov. 8, 2018, 7:41 p.m.