penalized_fine_gray() fits the Fine-Gray model for the subdistribution hazard of one cause
with an elastic-net penalty, for when there are many covariates for the number of events of
that cause, or covariates that are strongly correlated. The coefficients minimize the negative
log pseudo partial likelihood of fine_gray(), divided by the number of subjects \(n\), plus
the penalty
$$\lambda \left(\alpha \|\beta\|_1 + \frac{1 - \alpha}{2} \|\beta\|_2^2\right),$$
with \(\lambda\) the penalizer and \(\alpha\) the l1_ratio. l1_ratio = 1 is the lasso,
which sets some coefficients to exactly 0 and so selects covariates. l1_ratio = 0 is ridge
regression, which shrinks all of the coefficients toward 0 without removing any. Values in
between mix the two. penalizer = 0 gives the unpenalized fine_gray() fit.
Usage
penalized_fine_gray(
formula,
data,
cause = 1,
subset,
na.action = stats::na.omit,
penalizer = 0.1,
l1_ratio = 0.5,
standardize = TRUE,
max_iter = 1000,
tol = 1e-07
)Arguments
- formula
A formula with a competing-risks response on the left,
Surv(time, event)witheventa factor whose first level is censoring, and the covariates on the right, such asSurv(time, event) ~ age + sex. Factors are coded with treatment contrasts. Collinear covariates are allowed.- data
A data frame holding the variables in
formula.- cause
The cause to model, a level of
eventor its number among the causes. The default is the first cause.- subset
An optional expression selecting the rows of
datato use.- na.action
What to do with rows that have missing values. The default drops them.
- penalizer
The penalty strength \(\lambda\), a non-negative number. The default is
0.1.- l1_ratio
The elastic-net mixing \(\alpha\), between 0 (ridge) and 1 (lasso). The default is
0.5.- standardize
Whether to penalize each covariate on the scale of its standard deviation. The default is
TRUE.- max_iter
The largest number of iterations. The default is
1000.- tol
The convergence tolerance for the relative change in the coefficients. The default is
1e-7.
Value
A penalized_fine_gray object. Use coef() or as.data.frame() for the coefficients
and predict() for linear predictors, risk scores, and cumulative incidence curves. The
object also holds loglik (the log pseudo partial likelihood at the estimate), n_nonzero,
center and scale (each covariate's mean and the scale it was penalized on), cause,
states, n, n_event (the number of events of the cause), iterations, and converged.
Details
Subjects with a competing event stay in the risk sets after it, with the weight
\(G(t-) / G(T-)\), where \(G\) is the Kaplan-Meier curve of the censoring times and
\(T\) the time of the competing event, as in fine_gray().
With standardize = TRUE (the default), each covariate is penalized on the scale of its
standard deviation, so the penalty treats all of them alike whatever their units. The
coefficients are reported on the scale of the covariates either way. The fit uses accelerated
proximal gradient descent (FISTA) from \(\beta = 0\), with a backtracking line search, and
stops once the relative change in the coefficients is below tol. Penalized coefficients are
biased toward 0 by design, so no standard errors or p-values are given.
See also
fine_gray() for the unpenalized model, and cox_net() for the penalized Cox model.
Examples
mgus <- data.frame(
time = c(30, 45, 60, 72, 80, 95, 110, 120, 130, 150, 160, 180, 200, 210, 220, 240, 45, 95),
status = c(1, 2, 0, 2, 1, 2, 0, 1, 2, 2, 0, 1, 1, 2, 0, 2, 0, 1),
age = c(62, 75, 58, 80, 66, 71, 59, 64, 77, 82, 60, 68, 55, 79, 63, 74, 70, 61),
hgb = c(13, 12, 14, 11, 13, 12, 15, 12, 11, 10, 14, 13, 12, 11, 15, 12, 13, 12)
)
mgus$event <- factor(mgus$status, levels = 0:2, labels = c("censor", "pcm", "death"))
# The lasso, which sets some coefficients to 0
fit <- penalized_fine_gray(Surv(time, event) ~ age + hgb,
data = mgus, cause = "pcm", penalizer = 0.1, l1_ratio = 1
)
fit
#> <penalized_fine_gray> Surv(time, event) ~ age + hgb
#> Elastic net, penalizer = 0.1, l1_ratio = 1. Subdistribution hazards for cause "pcm".
#> n = 18, events = 6
#>
#> estimate hazard_ratio
#> age -0.06985 0.9325
#> hgb 0.00000 1.0000
#>
#> Nonzero coefficients: 1 of 2. Log pseudo partial likelihood = -12.838
# Cumulative incidence of the cause for new subjects
predict(fit, newdata = data.frame(age = c(60, 75), hgb = c(14, 11)), type = "cif",
times = c(100, 200)
)
#> subject time estimate
#> 1 1 100 0.2624364
#> 2 1 200 0.6001020
#> 3 2 100 0.1012641
#> 4 2 200 0.2749165