iregnet: Fit interval censored AFT models with elastic net...

Description Usage Arguments Details Value References Author(s) See Also Examples

View source: R/iregnet.R

Description

Fit accelerated failure time models using interval censored data via elastic net penalized maximum likeihood. Solutions are computed using coordinate descent for a path of values of the regularization parameter lambda. Supports gaussian, logistic and extreme value distributions.

Usage

1
2
3
4
5
6
iregnet(x, y, family = c("gaussian", "logistic", "loggaussian",
  "loglogistic", "extreme_value", "exponential", "weibull"), alpha = 1,
  lambda = NULL, num_lambda = 100, intercept = TRUE,
  standardize = TRUE, scale_init = NA, estimate_scale = TRUE,
  maxiter = 1000, threshold = 0.001, unreg_sol = TRUE,
  eps_lambda = NA, debug = 0)

Arguments

x

Input matrix of covariates with dimension n_obs * n_vars, with nvars ≥ 2. Sparse matrices are not supported.

y

Response variable. It can take two forms:

  • 2 column real matrix with NAs denoting a censored observation

  • Surv object. Supported types of Surv are 'left', 'right', 'interval' and 'interval2'.

family

The distribution to fit. It can be one of "gaussian", "logistic", "loggaussian", "loglogistic", "extreme_value", "exponential". Partial matching is allowed.
Default: "gaussian"

alpha

Elastic net mixing parameter, with 0 ≤ α ≤ 1. The elastic net penalty is defined as in glmnet:

0.5 * (1-α) \|β\|_2^2 | + α \|β\|_1

alpha=1 is the lasso penalty, and alpha=0 is ridge penalty.
Default: 1

lambda

Vector containing the path of decreasing regularization parameter lambda values.
If not supplied, the function will calculate a lambda path of length num_lambda itself. NOTE: The lambda values are scaled because of the nuisance parameter, and hence not directly comparable to those of other packages like glmnet.
Default: NA

num_lambda

The number of lambda values calculated by the function. Ignored if lambda is supplied by the user.
Default: 100

intercept

TRUE if an intercept is to be fit, otherwise FALSE. Intercept is calculated by appending a column of 1s to x.
Default: TRUE

standardize

TRUE if x must be standardized before fit, otherwise FALSE. Calculated beta are scaled to original scale before returning.
Default: TRUE

scale_init

Initial value of the scale parameter to use. If not supplied, a suitable value is calculated depending on the distribution.
Default: NA

estimate_scale

TRUE if scale is to be estimated. To use a fixed value scale0 for scale, set scale_init=scale0 , estimate_scale=FALSE. See examples.
Default: TRUE

maxiter

Maximum number of iterations over data per lambda value.
Default: 1e3

threshold

The convergence threshold for coordinate descent. The inner loop continues until the absolute update in each parameter is greater than threshold.
Default: 1e-4

unreg_sol

TRUE if the final solution computed must be unregularized. Overwritten to FALSE if n_vars > n_obs. Only used if lambda_path is not specified.
Default: TRUE

eps_lambda

The ratio of the minimum value of lambda to the (calculated) maximum value, in case no lambda is supplied. num_lambda lambda values are calculated between lambda_max and lambda_min on the log scale.
Default: 0.0001 if n_vars < n_obs, 0.1 otherwise.

debug

TRUE if code debugging messages must be printed.
Default: FALSE

Details

At each regularization parater value lambda, cyclic coordinate descent is used to update the parameters until convergence. The intercept and the scale parameter are never regularized. The obtained solution is used to initialize the parameters at the next lambda value.

Value

Returns a S3 object iregnet with the following elements:

beta Matrix of size (n_vars+1) * num_lambda containing intercept, coefficients of X for each lambda in the fit model.
call Copy of the call that produced this object.
lambda Vector of size num_lambda of (calculated or supplied) regularization parameter lambda values.
loglik Vector of size num_lambda of log-likelihoods of the fit at each lambda value, excluding the contribution of the penalty terms.
num_lambda Number of lambda values.
n_iters Vector of size num_lambda of number of iterations taken at each lambda.
scale Vector of size num_lambda of estimated scale at each lambda value, if estimate_scale == TRUE. Same as scale_init otherwise.
scale_init Initial value (calculated or supplied) of scale.
estimate_scale TRUE if the scale was estimated.
error_status The error status. 0 denotes no errors. -1 denotes that convergence was not reached in maxiter.

References

Friedman, J., Hastie, T. and Tibshirani, R. (2008) Regularization Paths for Generalized Linear Models via Coordinate Descent, http://www.stanford.edu/~hastie/Papers/glmnet.pdf

Simon, N., Friedman, J., Hastie, T., Tibshirani, R. (2011) Regularization Paths for Cox's Proportional Hazards Model via Coordinate Descent, Journal of Statistical Software, Vol. 39(5) 1-13 http://www.jstatsoft.org/v39/i05/

Author(s)

Anuj Khare, Toby Dylan Hocking, Jelle Goeman.
Maintainer: Anuj Khare khareanuj18@gmail.com

See Also

predict.iregnet, cv.iregnet, plot.iregnet

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# y can be a 2 column matrix.
set.seed(10)
X <- matrix(rnorm(50), 10, 5)
y <- matrix(rnorm(20), 10, 2)
y <- t(apply(y, 1, sort)) # intervals must be non-decreasing
fit1 <- iregnet(X, y)

# Surv objects from survival are also supported.
data("ovarian", package="survival")
library(survival)
X <- cbind(ovarian$ecog.ps, ovarian$rx)
y <- Surv(ovarian$futime, ovarian$fustat)
fit2 <- iregnet(X, y)

# Log-Gaussian is same as Gaussian with log-transformed data
X <- cbind(ovarian$ecog.ps, ovarian$rx)
y <- Surv(ovarian$futime, ovarian$fustat)
y_log <- Surv(log(ovarian$futime), ovarian$fustat)
fit3 <- iregnet(X, y_log, "gaussian", threshold=1e-2)
fit4 <- iregnet(X, y, "loggaussian", threshold=1e-2)

# Scale parameter can be fixed by setting the estimate_scale flag.
set.seed(10)
X <- matrix(rnorm(50), 10, 5)
y <- matrix(rnorm(20), 10, 2)
y <- t(apply(y, 1, sort)) # intervals must be non-decreasing
fit5 <- iregnet(X, y, scale_init=1, estimate_scale=FALSE)

anujkhare/iregnet documentation built on Aug. 23, 2019, 8:24 p.m.