Internal helper function to easily return the correct survival predict types.
Usage
.surv_return(
times = NULL,
surv = NULL,
crank = NULL,
lp = NULL,
response = NULL,
which.curve = NULL
)
Arguments
- times
(
numeric()
)
Vector of survival times.- surv
(
matrix()|array()
)
Matrix or array of predicted survival probabilities, rows (1st dimension) are observations, columns (2nd dimension) are times and in the case of an array there should be one more dimension. Number of columns should be equal to length oftimes
. In case anumeric()
vector is provided, it is converted to a single row (one observation) matrix.- crank
(
numeric()
)
Relative risk/continuous ranking. Higher value is associated with higher risk. IfNULL
then either set as-response
if available orlp
if available (this assumes that thelp
prediction comes from a PH type model - in case of an AFT model the user should provide-lp
). In case neitherresponse
orlp
are provided, thencrank
is calculated as the sum of the cumulative hazard function (expected mortality) derived from the predicted survival function (surv
), see get_mortality. In casesurv
is a 3d array, we use thewhich.curve
parameter to decide which survival matrix (index in the 3rd dimension) will be chosen for the calculation ofcrank
.- lp
(
numeric()
)
Predicted linear predictor, used to imputecrank
ifNULL
.- response
(
numeric()
)
Predicted survival time, passed through function without modification.- which.curve
Which curve (3rd dimension) should the
crank
be calculated for, in casesurv
is anarray
? If between (0,1) it is taken as the quantile of the curves otherwise if greater than 1 it is taken as the curve index. It can also be 'mean' and the survival probabilities are averaged across the 3rd dimension. Default value (NULL
) is the 0.5 quantile which is the median across the 3rd dimension of the survival array.
References
Sonabend, Raphael, Bender, Andreas, Vollmer, Sebastian (2022). “Avoiding C-hacking when evaluating survival distribution predictions with discrimination measures.” Bioinformatics. ISSN 1367-4803, doi:10.1093/BIOINFORMATICS/BTAC451 , https://academic.oup.com/bioinformatics/advance-article/doi/10.1093/bioinformatics/btac451/6640155.