| coxkl_enet | R Documentation |
Fits a Cox proportional hazards model that incorporates external information
using Kullback–Leibler (KL) divergence, with an optional L1 (Lasso) or elastic net penalty on
the coefficients. External information can be supplied either as precomputed external
risk scores (RS) or as externally derived coefficients (beta). The integration
strength is controlled by the tuning parameter eta.
coxkl_enet(
z,
delta,
time,
stratum = NULL,
RS = NULL,
beta = NULL,
eta = NULL,
alpha = NULL,
lambda = NULL,
nlambda = 100,
lambda.min.ratio = ifelse(n < p, 0.05, 0.001),
lambda.early.stop = FALSE,
tol = 1e-04,
Mstop = 1000,
max.total.iter = (Mstop * nlambda),
group = 1:ncol(z),
group.multiplier = NULL,
standardize = TRUE,
nvar.max = ncol(z),
group.max = length(unique(group)),
stop.loss.ratio = 0.001,
actSet = TRUE,
actIter = Mstop,
actGroupNum = sum(unique(group) != 0),
actSetRemove = FALSE,
returnX = FALSE,
trace.lambda = FALSE,
message = FALSE,
data_sorted = FALSE,
...
)
z |
Numeric matrix of covariates with rows representing observations and columns representing predictor variables. All covariates must be numeric. |
delta |
Numeric vector of event indicators (1 = event, 0 = censored). |
time |
Numeric vector of observed event or censoring times. No sorting required. |
stratum |
Optional numeric or factor vector defining strata. |
RS |
Optional numeric vector or matrix of external risk scores. Length
(or number of rows) must equal the number of observations. If not supplied,
|
beta |
Optional numeric vector of external coefficients (e.g., from prior
studies). Length must equal the number of columns in |
eta |
Numeric tuning parameter controlling the reliance on external information. Larger values place more weight on the external source. |
alpha |
Elastic-net mixing parameter in |
lambda |
Optional nonnegative penalty parameter(s). If a numeric vector
is supplied, the path is taken as-is. If |
nlambda |
Integer number of lambda values to generate when |
lambda.min.ratio |
Ratio of the smallest to the largest lambda when
generating a sequence (when |
lambda.early.stop |
Logical; if |
tol |
Convergence tolerance for the optimization algorithm. Default is
|
Mstop |
Maximum number of iterations for the inner optimization at a
given lambda. Default is |
max.total.iter |
Maximum total iterations across the entire lambda path.
Default is |
group |
Integer vector of group indices defining group
membership of predictors for grouped penalties; use |
group.multiplier |
A vector of values representing multiplicative factors by which each covariate's penalty is to be multiplied. Default is a vector of 1's. |
standardize |
Logical; if |
nvar.max |
Integer cap on the number of active variables allowed during fitting. Default number of predictors. |
group.max |
Integer cap on the number of active groups allowed during fitting. Default total number of groups. |
stop.loss.ratio |
Relative improvement threshold for early stopping along
the path; optimization may stop if objective gain falls below this value.
Default |
actSet |
Logical; if |
actIter |
Maximum number of active-set refinement iterations per lambda.
Default |
actGroupNum |
Maximum number of active groups allowed under the active-set scheme. |
actSetRemove |
Logical; if |
returnX |
Logical; if |
trace.lambda |
Logical; if |
message |
Logical; if |
data_sorted |
Logical; if |
... |
Additional arguments. |
Setting lambda = 0 reduces to the unpenalized coxkl model.
When lambda > 0, the model fits a KL-regularized Cox objective with an
elastic-net penalty:
\ell_{\mathrm{KL}}(\beta;\eta) \;-\; \lambda\Big\{ \alpha\|\beta\|_1 \;+\; (1-\alpha)\tfrac{1}{2}\|\beta\|_2^2 \Big\},
where \alpha=1 gives lasso and 0<\alpha<1 gives elastic net. Grouped
penalties are supported via group (use 0 for unpenalized variables), with optional
per-group scaling through group.multiplier. If lambda is NULL, a decreasing path
of length nlambda is generated using lambda.min.ratio; early stopping can prune the
path (lambda.early.stop, stop.loss.ratio). When standardize = TRUE, predictors are
standardized for fitting and coefficients are rescaled on output. If data_sorted = FALSE,
data are sorted by stratum then time for optimization and predictions are returned in
the original order (reported via W = exp(linear predictors)). An active-set scheme
(actSet, actIter, nvar.max, group.max, actGroupNum, actSetRemove) is used to
accelerate the solution along the lambda path.
An object of class "coxkl_enet", a list with components:
betaCoefficient estimates (vector or matrix across the path).
groupA factor of the original group assignments.
lambdaThe lambda value(s) used or generated.
alphaThe elastic-net mixing parameter used.
likelihoodVector of log-partial likelihoods for each lambda.
nNumber of observations.
dfEffective degrees of freedom (e.g., number of nonzero coefficients or group-adjusted count) along the path.
iterNumber of iterations taken (per lambda and/or total).
WExponentiated linear predictors on the original scale.
group.multiplierGroup-specific penalty multipliers used.
returnXOnly when returnX = TRUE: a list with elements
XX (standardization/orthogonalization info from std.Z),
time, delta, stratum, and RS.
coxkl
data(ExampleData_highdim)
train_dat_highdim <- ExampleData_highdim$train
beta_external_highdim <- ExampleData_highdim$beta_external
model_enet <- coxkl_enet(z = train_dat_highdim$z,
delta = train_dat_highdim$status,
time = train_dat_highdim$time,
beta = beta_external_highdim,
eta = 0,
alpha = 1.0)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.