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. IfNULLthen either set as-responseif available orlpif available (this assumes that thelpprediction comes from a PH type model - in case of an AFT model the user should provide-lp). In case neitherresponseorlpare provided, thencrankis calculated as the sum of the cumulative hazard function (expected mortality) derived from the predicted survival function (surv). In casesurvis a 3d array, we use thewhich.curveparameter to decide which survival matrix (index in the 3rd dimension) will be chosen for the calculation ofcrank.- lp
(
numeric())
Predicted linear predictor, used to imputecrankifNULL.- response
(
numeric())
Predicted survival time, passed through function without modification.- which.curve
Which curve (3rd dimension) should the
crankbe calculated for, in casesurvis 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.
Details
Uses survivalmodels::surv_to_risk to reduce survival matrices to relative
risks / rankings if crank is NULL.