penAFT: Fit the solution path for the regularized semiparametric...

View source: R/penAFT.R

penAFTR Documentation

Fit the solution path for the regularized semiparametric accelerated failure time model with weighted elastic net or weighted sparse group lasso penalties.

Description

A function to fit the solution path for the regularized semiparametric accelerated failure time model estimator.

Usage

penAFT(X, logY, delta, nlambda = 50, 
  lambda.ratio.min = 0.1, lambda = NULL, 
  penalty = NULL, alpha = 1, weight.set = NULL, 
  groups = NULL, tol.abs = 1e-8, tol.rel = 2.5e-4, 
  gamma = 0,  standardize = TRUE, 
  admm.max.iter = 1e4, quiet=TRUE)

Arguments

X

An n \times p matrix of predictors. Observations should be organized by row.

logY

An n-dimensional vector of log-survival or log-censoring times.

delta

An n-dimensional binary vector indicating whether the jth component of logY is an observed log-survival time (\delta_j = 1) or a log-censoring time (\delta_j = 0) for j=1, \dots, n.

nlambda

The number of candidate tuning parameters to consider.

lambda.ratio.min

The ratio of maximum to minimum candidate tuning parameter value. As a default, we suggest 0.1, but standard model selection procedures should be applied to select \lambda.

lambda

An optional (not recommended) prespecified vector of candidate tuning parameters. Should be in descending order.

penalty

Either "EN" or "SG" for elastic net or sparse group lasso penalties.

alpha

The tuning parameter \alpha. See documentation.

weight.set

A list of weights. For both penalties, w is an n-dimensional vector of nonnegative weights. For "SG" penalty, can also include v – a non-negative vector the length of the number of groups. See documentation for usage example.

groups

When using penalty "SG", a p-dimensional vector of integers corresponding the to group assignment of each predictor (i.e., column of X).

tol.abs

Absolute convergence tolerance.

tol.rel

Relative convergence tolerance.

gamma

A non-negative optimization parameter which can improve convergence speed in certain settings. It is highly recommended to set equal to zero.

standardize

Should predictors be standardized (i.e., column-wise average zero and scaled to have unit variance) for model fitting?

admm.max.iter

Maximum number of ADMM iterations.

quiet

TRUE or FALSE variable indicating whether progress should be printed.

Details

Given (\log y_1, x_1, \delta_1),\dots,(\log y_n, x_n, \delta_n) where y_i is the minimum of the survival time and censoring time, x_i is a p-dimensional predictor, and \delta_i is the indicator of censoring, penAFT fits the solution path for the argument minimizing

\frac{1}{n^2}\sum_{i=1}^n \sum_{j=1}^n \delta_i \{ \log y_i - \log y_j - (x_i - x_j)'\beta \}^{-} + \lambda g(\beta)

where \{a \}^{-} := \max(-a, 0) , \lambda > 0, and g is either the weighted elastic net penalty (penalty = "EN") or weighted sparse group lasso penalty (penalty = "SG"). The weighted elastic net penalty is defined as

\alpha \| w \circ \beta\|_1 + \frac{(1-\alpha)}{2}\|\beta\|_2^2

where w is a set of non-negative weights (which can be specified in the weight.set argument). The weighted sparse group-lasso penalty we consider is

\alpha \| w \circ \beta\|_1 + (1-\alpha)\sum_{l=1}^G v_l\|\beta_{\mathcal{G}_l}\|_2

where again, w is a set of non-negative weights and v_l are weights applied to each of the G groups.

Value

beta

A p \times nlambda sparse matrix consisting of the estimates of \beta for the candidate values of \lambda. It is recommended to use penAFT.coef to extract coefficients.

lambda

The candidate tuning parameter values.

standardize

Were predictors standardized to have unit variance for model fitting?

X.mean

The mean of the predictors.

X.sd

The standard deviation of the predictors.

alpha

The tuning parameter \alpha. See documentation.

Examples

# --------------------------------------
# Generate data  
# --------------------------------------
set.seed(1)
genData <- genSurvData(n = 50, p = 50, s = 10, mag = 2, cens.quant = 0.6)
X <- genData$X
logY <- genData$logY
delta <- genData$status


# -----------------------------------------------
# Fit elastic net penalized estimator
# -----------------------------------------------
fit.en <- penAFT(X = X, logY = logY, delta = delta,
                   nlambda = 50, lambda.ratio.min = 0.01,
                   penalty = "EN",
                   alpha = 1)
                   

coef.en.10 <- penAFT.coef(fit.en, lambda = fit.en$lambda[10])


# ------------------------------------------------
# Fit weighted elastic net penalized estimator
# ------------------------------------------------
weight.set <- list("w" = c(0, 0, rep(1, 48)))
fit.weighted.en <- penAFT(X = X, logY = logY, delta = delta,
                   nlambda = 50, weight.set = weight.set,
                   penalty = "EN",
                   alpha = 1)
coef.wighted.en.10 <- penAFT.coef(fit.weighted.en, lambda = fit.weighted.en$lambda[10])
                   
                   
# ------------------------------------------------
# Fit ridge penalized estimator with user-specified lambda
# ------------------------------------------------
fit.ridge <- penAFT(X = X, logY = logY, delta = delta,
                   lambda = 10^seq(-4, 4, length=50), 
                   penalty = "EN",
                   alpha = 0)
                   
                   
# -----------------------------------------------
# Fit sparse group penalized estimator
# -----------------------------------------------
groups <- rep(1:5, each = 10)
fit.sg <- penAFT(X = X, logY = logY, delta = delta,
                   nlambda = 50, lambda.ratio.min = 0.01,
                   penalty = "SG", groups = groups, 
                   alpha = 0.5)
                   
# -----------------------------------------------
# Fit weighted sparse group penalized estimator
# -----------------------------------------------
groups <- rep(1:5, each = 10)
weight.set <- list("w" = c(0, 0, rep(1, 48)), 
      "v" = 1:5)
fit.weighted.sg <- penAFT(X = X, logY = logY, delta = delta,
                   nlambda = 100, 
                   weight.set = weight.set,
                   penalty = "SG", groups = groups, 
                   alpha = 0.5)

coef.weighted.sg.20 <- penAFT.coef(fit.weighted.sg, lambda = fit.weighted.sg$lambda[20])


penAFT documentation built on April 18, 2023, 9:10 a.m.