Skip to contents

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 of times. In case a numeric() 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. If NULL then either set as -response if available or lp if available (this assumes that the lp prediction comes from a PH type model - in case of an AFT model the user should provide -lp). In case neither response or lp are provided, then crank is calculated as the sum of the cumulative hazard function (expected mortality) derived from the predicted survival function (surv), see get_mortality. In case surv is a 3d array, we use the which.curve parameter to decide which survival matrix (index in the 3rd dimension) will be chosen for the calculation of crank.

lp

(numeric())
Predicted linear predictor, used to impute crank if NULL.

response

(numeric())
Predicted survival time, passed through function without modification.

which.curve

Which curve (3rd dimension) should the crank be calculated for, in case surv is an array? 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.