s_factory {survobj} | R Documentation |
Factory of objects of class SURVIVAL
Description
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 |
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
generic S3:
plot.SURVIVAL()
-
plot_survival()
: to plot the functions -
ggplot_survival_random()
: to ggplot random draws from the distribution -
compare_survival()
: to compare the functions of two SURVIVAL objects
Value
a SURVIVAL object
Distributions
The current factories are implemented:
-
s_exponential()
: for Exponential distributions -
s_weibull()
: for Weibull distributions -
s_gompertz()
: for Gompertz distributions -
s_picewise()
: for Piecewise exponential distributions
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)
hfx(SURVIVAL = obj, t = 0.4)
Cum_Hfx(SURVIVAL = obj, t = 0.4)
# Time when the Cumulative hazard is 0.8
invCum_Hfx(SURVIVAL = obj, H = 0.8)
# Draw one random survival time from the distribution
rsurv(SURVIVAL = obj, n = 1)
# Draw one random survival time from the distribution, with hazard ratio 0.5
rsurvhr(SURVIVAL = obj, hr = 0.5)
# Plot the survival functions
plot(obj)