Skip to contents

Create objects of the class SURVIVAL

Usage

s_factory(s_family, ...)

Arguments

s_family

a factory for a specific distribution

...

parameters to define the survival distribution

Value

a SURVIVAL object

Details

The objects of the class SURVIVAL define different distributions of survival times. Each class has its own set of parameters but once the SURVIVAL object is defined, they have access to the same functions to calculate:

  • survival time function: sfx(),

  • hazard time function: hfx(),

  • cumulative hazard function: Cum_Hfx()

  • the inverse of the cumulative hazard function: invCum_Hfx().

  • generate random survival times: rsurv()

  • generate random survival times under proportional hazard ratio: rsurvhr().

There several functions to plot the distributions

Distributions

The current factories are implemented:

Examples

# Define a SURVIVAL object
obj <- s_factory(s_exponential, lambda = 2)

# Survival, Hazard and Cumulative hazard at time 0.4
sfx(SURVIVAL = obj, t= 0.4)
#> [1] 0.449329
hfx(SURVIVAL = obj, t = 0.4)
#> [1] 2
Cum_Hfx(SURVIVAL = obj, t = 0.4)
#> [1] 0.8

# Time when the Cumulative hazard is 0.8
invCum_Hfx(SURVIVAL = obj, H = 0.8)
#> [1] 0.4

# Draw one random survival time from the distribution
rsurv(SURVIVAL = obj, n = 1)
#> [1] 0.1737629

# Draw one random survival time from the distribution, with hazard ratio 0.5
rsurvhr(SURVIVAL = obj, hr = 0.5)
#> [1] 0.05279276

# Plot the survival functions
plot(obj)