Validates the structure, optional cause names, time points, and probabilities in a list of cumulative incidence function (CIF) matrices. This is the format used by PredictionCompRisks to store the predictions of competing risk models.
Uses survdistr::assert_prob() with type = "cif".
Arguments
- x
(
list())
List of numeric matrices (at least two), one per competing event. Names are checked only whencausesis supplied. CIF matrix rows represent observations, and columns represent time points.- times
(
list()|NULL)
List of numeric time vectors, one per competing event. Each vector must have one entry (i.e. time point) per corresponding CIF matrix column. Names are checked only whencausesis supplied. IfNULL, time points are taken from each matrix's column names.- n_rows
(
integer(1)|NULL)
Expected number of observations in each matrix. IfNULL, no specific row count is required.- causes
(
character()|NULL)
Expected unique, nonempty competing event names or codes. If supplied, these must match the list names exactly (both inxandtimes), including their order. IfNULL, list names are not checked, and unnamed lists are accepted.
Details
CIF matrices may use different time grids.
See survdistr::assert_prob() for the probability and time point validation
rules for type = "cif".
Examples
cif = list(
"Death" = matrix(c(0, 0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.4), nrow = 2L),
"Relapse" = matrix(c(0, 0, 0.2, 0.1, 0.4, 0.3), nrow = 2L)
)
times = list(Death = 0:3, Relapse = 0:2)
assert_cif_list(cif, times, n_rows = 2L, causes = c("Death", "Relapse"))
# Alternatively, supply time points through column names
colnames(cif$Death) = times$Death
colnames(cif$Relapse) = times$Relapse
cif
#> $Death
#> 0 1 2 3
#> [1,] 0 0.1 0.3 0.5
#> [2,] 0 0.2 0.4 0.4
#>
#> $Relapse
#> 0 1 2
#> [1,] 0 0.2 0.4
#> [2,] 0 0.1 0.3
#>
assert_cif_list(cif)
