ipc_ridge() fits a linear model for the log survival time, correcting for censoring by
inverse-probability-of-censoring (IPC) weighting rather than by a likelihood. Only the subjects
with an event enter the fit, each weighted by \(w_i = 1 / G(T_i-)\), where \(G\) is the
Kaplan-Meier estimate of the censoring distribution (see censoring_distribution()). The
coefficients minimize
$$\sum_{i: \delta_i = 1} w_i (\log T_i - \beta_0 - x_i^\top \beta)^2 +
\alpha \sum_j (s_j \beta_j)^2,$$
so no proportional hazards or error distribution is assumed.
Usage
ipc_ridge(
formula,
data,
weights,
subset,
na.action = stats::na.omit,
alpha = 1,
standardize = TRUE
)Arguments
- formula
A formula with a right-censored
Surv()response on the left and the covariates on the right, such asSurv(time, status) ~ age + sex. Factors are coded with treatment contrasts.- data
A data frame holding the variables in
formula.- weights
Optional case weights, a column of
dataor a numeric vector.- 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.
- alpha
The ridge penalty, a non-negative number.
0gives the unpenalized IPC-weighted least squares fit. The default is1.- standardize
Whether to penalize each covariate on the scale of its standard deviation. The default is
TRUE.
Value
An ipc_ridge object. Use coef() or as.data.frame() for the coefficients and
predict() for the predicted log times or times. The object also holds ipc_weights (one per
row, 0 for the censored), censoring (the censoring_distribution()), scale (the
\(s_j\)), n, and n_event (the number of events in the fit).
Details
The intercept isn't penalized. With standardize = TRUE (the default), \(s_j\) is the
standard deviation of covariate \(j\) among the subjects with an event, so each covariate is
penalized on its own scale. With standardize = FALSE, \(s_j = 1\). Either way, the
coefficients are on the scale of the covariates. Case weights multiply the IPC weights and
also weight the censoring distribution, so whole-number weights act as copies of rows.
Examples
lung <- data.frame(
time = c(306, 455, 1010, 210, 883, 1022, 310, 361, 218, 166, 170, 654, 728, 71, 567, 144,
613, 707, 61, 88),
status = c(2, 2, 1, 2, 2, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 1, 2, 2, 2, 2),
age = c(74, 68, 56, 57, 60, 74, 68, 71, 53, 61, 57, 68, 68, 60, 57, 67, 70, 63, 56, 57),
sex = c(1, 1, 1, 1, 1, 1, 2, 2, 1, 1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 1)
)
fit <- ipc_ridge(Surv(time, status) ~ age + sex, data = lung, alpha = 1)
fit
#> <ipc_ridge> Surv(time, status) ~ age + sex
#> IPC-weighted ridge, alpha = 1. n = 20, events = 16 (used for fitting)
#>
#> estimate
#> (Intercept) 2.27906
#> age 0.05331
#> sex 0.03844
# Predicted survival times for two new subjects
newdata <- data.frame(age = c(55, 70), sex = c(1, 2))
predict(fit, newdata = newdata, type = "response")
#> [1] 190.4641 440.3344