| cv.coxkl | R Documentation |
eta) for the Cox–KL ModelPerforms K-fold cross-validation to select the integration parameter eta
for the Cox–KL model. Each fold fits the model on a training split and
evaluates on the held-out split using the specified performance criterion.
cv.coxkl(
z,
delta,
time,
stratum = NULL,
RS = NULL,
beta = NULL,
etas = NULL,
tol = 1e-04,
Mstop = 100,
backtrack = FALSE,
nfolds = 5,
criteria = c("V&VH", "LinPred", "CIndex_pooled", "CIndex_foldaverage"),
c_index_stratum = NULL,
message = FALSE,
seed = NULL,
...
)
z |
Numeric matrix of covariates (rows = observations, columns = variables). |
delta |
Numeric vector of event indicators (1 = event, 0 = censored). |
time |
Numeric vector of observed event or censoring times. |
stratum |
Optional numeric or factor vector defining strata. If |
RS |
Optional numeric vector or matrix of external risk scores. If omitted,
|
beta |
Optional numeric vector of external coefficients. If omitted, |
etas |
Numeric vector of candidate tuning values to be cross-validated. (required). Values are internally sorted in ascending order. |
tol |
Convergence tolerance for the optimizer used inside |
Mstop |
Maximum number of Newton iterations used inside |
backtrack |
Logical; if |
nfolds |
Number of cross-validation folds. Default |
criteria |
Character string specifying the performance criterion.
Choices are |
c_index_stratum |
Optional stratum vector. Only required when
|
message |
Logical; if |
seed |
Optional integer seed for reproducible fold assignment. Default |
... |
Additional arguments passed to |
External information is required: supply either RS or beta (if beta is given,
RS is computed as z %*% beta). Folds are created with stratification by
stratum and censoring status. Within each fold and each candidate eta,
the function fits coxkl on the training split with warm-starts initialized to zero
and evaluates on the test split:
"V&VH": uses the difference of partial log-likelihoods between full and
training fits; reported as -2 times the aggregated quantity.
"LinPred": aggregates the test-split linear predictors across folds and
evaluates -2 times the partial log-likelihood on the full data.
"CIndex_pooled": pools pairwise comparable counts across folds (numerator/denominator).
"CIndex_foldaverage": averages the per-fold stratified C-index.
The function also computes an external baseline statistic from RS using the
same criterion for comparison.
An object of class "cv.coxkl" with components:
internal_statA data.frame with one row per eta containing eta and the
cross-validated measure named according to criteria (one of
VVH_Loss, LinPred_Loss, CIndex_pooled, CIndex_foldaverage).
external_statScalar baseline statistic computed from RS under the same criteria.
criteriaThe evaluation criterion used.
nfoldsNumber of folds.
data(ExampleData_lowdim)
train_dat_lowdim <- ExampleData_lowdim$train
beta_external_good_lowdim <- ExampleData_lowdim$beta_external_good
etas <- generate_eta(method = "exponential", n = 10, max_eta = 5)
cv_res <- cv.coxkl(z = train_dat_lowdim$z,
delta = train_dat_lowdim$status,
time = train_dat_lowdim$time,
beta = beta_external_good_lowdim,
etas = etas)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.