Create a new object which stores user-specified survival distribution
information in the format needed for the main function, RMSTpow
. survdef
is used when the user wishes to specify a piecewise expoenential survival
distribution. Either the hazard on fixed intervals or survival probabilities
at fixed times can be specified.
survdef(haz = NA, surv = NA, times = NA)
haz | a vector of hazards of length<=10. If a single hazard is
specified, the survival distribution is exponential with the specified
hazard. If |
---|---|
surv | a vector of survival probabilities of length<=10 corresponding to
|
times | a vector of the same length as surv (if surv is specified) or one element shorter than haz (if haz is specified). No times term is required if a single hazard is specified in haz. |
a list with components:
a vectorized function that takes time as input and returns the survival probability at that time
a vectorized function that takes time as input and returns the hazard at that time
#> $S #> function (t) #> sapply(t, function(z) { #> width <- diff(c(0, times[times < z], z)) #> H <- sum(width * h(c(0, times[times < z]))) #> return(exp(-H)) #> }) #> <bytecode: 0x7fb666e41618> #> <environment: 0x7fb660a30720> #> #> $h #> function (x) #> { #> sapply(x, function(t) { #> if (0 <= t & t < times10[1]) #> myh[1] #> else if (times10[1] <= t & t < times10[2]) #> myh[2] #> else if (times10[2] <= t & t < times10[3]) #> myh[3] #> else if (times10[3] <= t & t < times10[4]) #> myh[4] #> else if (times10[4] <= t & t < times10[5]) #> myh[5] #> else if (times10[5] <= t & t < times10[6]) #> myh[6] #> else if (times10[6] <= t & t < times10[7]) #> myh[7] #> else if (times10[7] <= t & t < times10[8]) #> myh[8] #> else if (times10[8] <= t & t < times10[9]) #> myh[9] #> else if (times10[9] <= t) #> myh[10] #> }) #> } #> <bytecode: 0x7fb664eb3230> #> <environment: 0x7fb660a30720> #>