Final Production Wrapper for Ridge Regression (Tunable & Robust). Estimates a penalized Cox model using a pure Ridge penalty (alpha = 0).
Arguments
- time
Observed follow-up time.
- event
Observed event indicator.
- X
Training covariate data.frame.
- newdata
Test covariate data.frame to use for prediction.
- new.times
Times at which to obtain the predicted survivals.
- obsWeights
Observation weights.
- id
Optional cluster/individual ID indicator.
- nfolds
Number of folds for internal cross-validation to select lambda. Default is 10.
- ties
Tied-event approximation used for risk-score calibration:
"breslow"(default) or"efron".- survival_transform
Transformation from calibrated hazard increments to survival probabilities:
"exponential"(default) or"product_limit".- ...
Additional arguments passed to
cv.glmnet.
Value
A list containing:
fit: The fitted model object (e.g., the rawcoxphorxgb.Boosterobject). If the model fails to fit, this may be an object of classtry-error.pred: A numeric matrix of cross-validated survival predictions evaluated at the specifiednew.timesgrid.
Examples
if (requireNamespace("glmnet", quietly = TRUE)) {
data("metabric", package = "SuperSurv")
dat <- metabric[1:30, ]
x_cols <- grep("^x", names(dat))[1:3]
X <- dat[, x_cols, drop = FALSE]
newX <- X[1:5, , drop = FALSE]
times <- seq(50, 150, by = 50)
fit <- surv.ridge(
time = dat$duration,
event = dat$event,
X = X,
newdata = newX,
new.times = times,
nfolds = 3
)
dim(fit[["pred"]])
}
#> Warning: Starting in glmnet 5.1, the default Cox tie-handling method will change from 'breslow' to 'efron' (matching survival::coxph). To silence this message and lock in the v5.0 default, pass cox.ties = 'breslow' explicitly. To preview the v5.1 behavior, pass cox.ties = 'efron'.
#> Warning: Starting in glmnet 5.1, the default Cox tie-handling method will change from 'breslow' to 'efron' (matching survival::coxph). To silence this message and lock in the v5.0 default, pass cox.ties = 'breslow' explicitly. To preview the v5.1 behavior, pass cox.ties = 'efron'.
#> Warning: Starting in glmnet 5.1, the default Cox tie-handling method will change from 'breslow' to 'efron' (matching survival::coxph). To silence this message and lock in the v5.0 default, pass cox.ties = 'breslow' explicitly. To preview the v5.1 behavior, pass cox.ties = 'efron'.
#> Warning: Starting in glmnet 5.1, the default Cox tie-handling method will change from 'breslow' to 'efron' (matching survival::coxph). To silence this message and lock in the v5.0 default, pass cox.ties = 'breslow' explicitly. To preview the v5.1 behavior, pass cox.ties = 'efron'.
#> [1] 5 3
