Skip to contents

All the SURVIVAL objects have access to the functions described here

Usage

sfx(SURVIVAL, t)

hfx(SURVIVAL, t)

Cum_Hfx(SURVIVAL, t)

invCum_Hfx(SURVIVAL, H)

rsurv(SURVIVAL, n)

rsurvhr(SURVIVAL, hr)

rsurvaft(SURVIVAL, aft)

rsurvah(SURVIVAL, aft, hr)

plot_survival(SURVIVAL, timeto, main)

ggplot_survival_random(SURVIVAL, timeto, subjects, nsim, alpha = 0.1)

compare_survival(SURVIVAL1, SURVIVAL2, timeto, main)

ggplot_survival_hr(SURVIVAL, hr, timeto, subjects, nsim, alpha = 0.1)

ggplot_survival_aft(SURVIVAL, aft, timeto, subjects, nsim, alpha = 0.1)

ggplot_survival_ah(SURVIVAL, aft, hr, timeto, subjects, nsim, alpha = 0.1)

Arguments

SURVIVAL

a SURVIVAL object

t

Time

H

cumulative hazard

n

number of observations

hr

hazard ratio

aft

accelerated failure time

timeto

plot the distribution up to timeto

main

title of the graph

subjects

number of subjects per group to simulate in each simulation

nsim

number of simulations

alpha

alpha value for the graph

SURVIVAL1

a SURVIVAL object

SURVIVAL2

a SURVIVAL object

Value

Depending on the function a proportion surviving, hazard, cumulative hazard, inverse of the cumulative hazard, a random draw or a plot

Functions

  • sfx(): Survival function

  • hfx(): Hazard function

  • Cum_Hfx(): Cumulative Hazard function

  • invCum_Hfx(): Inverse of the Cumulative Hazard function

  • rsurv(): Generate random values from the distribution

  • rsurvhr(): Generate random values from the distribution under proportional hazard ratios

  • rsurvaft(): Generate random values from the distribution under accelerated failure time ratios

  • rsurvah(): Generate random values from the distribution under accelerated hazard ratios

  • plot_survival(): Plot of the survival functions

  • ggplot_survival_random(): ggplot of the simulation of survival times

  • compare_survival(): Compare graphically two survival distributions

  • ggplot_survival_hr(): ggplot of the simulation of survival times with hazard ratios

  • ggplot_survival_aft(): ggplot of the simulation of survival times with accelerated time failures

  • ggplot_survival_ah(): ggplot of the simulation of survival times with accelerated hazard

Examples

#' # Define a SURVIVAL object
obj <- s_factory(s_weibull, surv = 0.8, t = 2, shape = 1.2)

# Survival, Hazard and Cumulative hazard at time 0.4
sfx(SURVIVAL = obj, t= 0.4)
#> [1] 0.9681716
hfx(SURVIVAL = obj, t = 0.4)
#> [1] 0.09703794
Cum_Hfx(SURVIVAL = obj, t = 0.4)
#> [1] 0.03234598

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

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

# Draw one random survival time from the distribution under Proportional
# hazard, Accelerated time failure or Accelerated hazard.
rsurvhr(SURVIVAL = obj, hr = 0.5)
#> [1] 2.994875
rsurvaft(SURVIVAL = obj, aft = 2)
#> [1] 1.989946
rsurvah(SURVIVAL = obj, aft = 2, hr = 0.5)
#> [1] 10.38445

# Plot the survival functions
plot_survival(SURVIVAL = obj, timeto = 2, main = "Example of Weibull distribution" )