Title: | Lasso and Elastic-Net Penalized Cox's Regression in High Dimensions Models using the Cocktail Algorithm |
---|---|
Description: | We implement a cocktail algorithm, a good mixture of coordinate decent, the majorization-minimization principle and the strong rule, for computing the solution paths of the elastic net penalized Cox's proportional hazards model. The package is an implementation of Yang, Y. and Zou, H. (2013) DOI: <doi:10.4310/SII.2013.v6.n2.a1>. |
Authors: | Yi Yang <[email protected]>, Hui Zou <[email protected]> |
Maintainer: | Yi Yang <[email protected]> |
License: | GPL-2 |
Version: | 1.1.3 |
Built: | 2024-11-04 04:48:48 UTC |
Source: | https://github.com/archer-yang-lab/fastcox |
We introduce a cocktail algorithm, a good mixture of coordinate decent, the majorization-minimization principle and the strong rule, for computing the solution paths of the elastic net penalized Cox's proportional hazards model.
Package: | fastcox |
Type: | Package |
Version: | 1.0.0 |
Date: | 2012-03-26 |
Depends: | Matrix |
License: | GPL (version 2) |
URL: | https://github.com/emeryyi/fastcox |
Yi Yang and Hui Zou
Maintainer: Yi Yang <[email protected]>
Yang, Y. and Zou, H. (2013),
"A Cocktail Algorithm for Solving The Elastic Net Penalized Cox's Regression in High Dimensions", Statistics and Its Interface, 6:2, 167-173.
https://github.com/emeryyi/fastcox
data(FHT) m1<-cocktail(x=FHT$x,y=FHT$y,d=FHT$status,alpha=0.5) predict(m1,type="nonzero") plot(m1)
data(FHT) m1<-cocktail(x=FHT$x,y=FHT$y,d=FHT$status,alpha=0.5) predict(m1,type="nonzero") plot(m1)
Fits a regularization path for the elastic net penalized Cox's model at a sequence of regularization parameters lambda.
cocktail(x,y,d, nlambda=100, lambda.min=ifelse(nobs<nvars,1e-2,1e-4), lambda=NULL, alpha=1, pf=rep(1,nvars), exclude, dfmax=nvars+1, pmax=min(dfmax*1.2,nvars), standardize=TRUE, eps=1e-6, maxit=3e4)
cocktail(x,y,d, nlambda=100, lambda.min=ifelse(nobs<nvars,1e-2,1e-4), lambda=NULL, alpha=1, pf=rep(1,nvars), exclude, dfmax=nvars+1, pmax=min(dfmax*1.2,nvars), standardize=TRUE, eps=1e-6, maxit=3e4)
x |
matrix of predictors, of dimension |
y |
a survival time for Cox models. Currently tied failure times are not supported. |
d |
censor status with 1 if died and 0 if right censored. |
nlambda |
the number of |
lambda.min |
given as a fraction of |
lambda |
a user supplied |
alpha |
The elasticnet mixing parameter, with |
pf |
separate penalty weights can be applied to each coefficient of |
exclude |
indices of variables to be excluded from the model. Default is none. Equivalent to an infinite penalty factor. |
dfmax |
limit the maximum number of variables in the
model. Useful for very large |
pmax |
limit the maximum number of variables ever to be nonzero. For example once |
standardize |
logical flag for variable standardization, prior to
fitting the model sequence. If |
eps |
convergence threshold for coordinate majorization descent. Each inner
coordinate majorization descent loop continues until the relative change in any
coefficient (i.e. |
maxit |
maximum number of outer-loop iterations allowed at fixed lambda value. Default is 1e4. If models do not converge, consider increasing |
The algorithm estimates based on observed data, through elastic net penalized log partial likelihood of Cox's model.
It can compute estimates at a fine grid of values of s in order to pick up a data-driven optimal
for fitting a 'best' final model. The penalty is a combination of l1 and l2 penalty:
alpha=1
is the lasso penalty.
For computing speed reason, if models are not converging or running slow, consider increasing eps
, decreasing
nlambda
, or increasing lambda.min
before increasing
maxit
.
FAQ:
Question: “I am not sure how are we optimizing alpha. I can get optimal lambda for each value of alpha. But how do I select optimum alpha?”
Answer: cv.cocktail
only finds the optimal lambda given alpha fixed. So to
chose a good alpha you need to fit CV on a grid of alpha, say (0.1,0.3, 0.6, 0.9, 1) and let cv.cocktail choose the optimal lambda for each alpha, then you choose the (alpha, lambda) pair that corresponds to the lowest predicted deviance.
Question: “I understand your are referring to minimizing the quantity cv.cocktail\$cvm
, the mean 'cross-validated error' to optimize alpha and lambda as you did in your implementation. However, I don't know what the equation of this error is and this error is not referred to in your paper either. Do you mind explaining what this is?
”
Answer: We first define the log partial-likelihood for the Cox model. Assume
is the estimate fitted on
-th fold, define the log partial likelihood function as
Then the log partial-likelihood deviance of the -th fold is defined
as
We now define the measurement we actually use for cross validation:
it is the difference between the log partial-likelihood deviance evaluated
on the full dataset and that evaluated on the on the dataset with
-th fold excluded. The cross-validated error is defined as
An object with S3 class cocktail
.
call |
the call that produced this object |
beta |
a |
lambda |
the actual sequence of |
df |
the number of nonzero coefficients for each value of
|
dim |
dimension of coefficient matrix (ices) |
npasses |
total number of iterations (the most inner loop) summed over all lambda values |
jerr |
error flag, for warnings and errors, 0 if no error. |
Yi Yang and Hui Zou
Maintainer: Yi Yang <[email protected]>
Yang, Y. and Zou, H. (2013),
"A Cocktail Algorithm for Solving The Elastic Net Penalized Cox's Regression in High Dimensions", Statistics and Its Interface, 6:2, 167-173.
https://github.com/emeryyi/fastcox
plot.cocktail
data(FHT) m1<-cocktail(x=FHT$x,y=FHT$y,d=FHT$status,alpha=0.5) predict(m1,type="nonzero") plot(m1)
data(FHT) m1<-cocktail(x=FHT$x,y=FHT$y,d=FHT$status,alpha=0.5) predict(m1,type="nonzero") plot(m1)
Does k-fold cross-validation for cocktail, produces a plot,
and returns a value for lambda
. This function is modified based on the cv
function from the glmnet
package.
cv.cocktail(x,y,d,lambda=NULL,nfolds=5,foldid,...)
cv.cocktail(x,y,d,lambda=NULL,nfolds=5,foldid,...)
x |
matrix of predictors, of dimension |
y |
a survival time for Cox models. Currently tied failure times are not supported. |
d |
censor status with 1 if died and 0 if right censored. |
lambda |
optional user-supplied lambda sequence; default is
|
nfolds |
number of folds - default is 5. Although |
foldid |
an optional vector of values between 1 and |
... |
other arguments that can be passed to cocktail. |
The function runs cocktail
nfolds
+1 times; the
first to get the lambda
sequence, and then the remainder to
compute the fit with each of the folds omitted. The average error and standard deviation over the
folds are computed.
an object of class cv.cocktail
is returned, which is a
list with the ingredients of the cross-validation fit.
lambda |
the values of |
cvm |
the mean cross-validated error - a vector of length
|
cvsd |
estimate of standard error of |
cvup |
upper curve = |
cvlo |
lower curve = |
nzero |
number of non-zero coefficients at each |
name |
a text string indicating partial likelihood (for plotting purposes). |
cocktail.fit |
a fitted |
lambda.min |
The optimal value of |
lambda.1se |
The largest value of |
Yi Yang and Hui Zou
Maintainer: Yi Yang <[email protected]>
Yang, Y. and Zou, H. (2013),
"A Cocktail Algorithm for Solving The Elastic Net Penalized Cox's Regression in High Dimensions", Statistics and Its Interface, 6:2, 167-173.
https://github.com/emeryyi/fastcox
Friedman, J., Hastie, T., and Tibshirani, R. (2010), "Regularization paths for generalized
linear models via coordinate descent," Journal of Statistical Software, 33, 1.
http://www.jstatsoft.org/v33/i01/
data(FHT) cv1<-cv.cocktail(x=FHT$x[,1:10],y=FHT$y,d=FHT$status,alpha=0.5,nfolds=3) cv1 plot(cv1)
data(FHT) cv1<-cv.cocktail(x=FHT$x[,1:10],y=FHT$y,d=FHT$status,alpha=0.5,nfolds=3) cv1 plot(cv1)
The FHT
data set has n = 50 observations and p = 100 predictors. The covariance between predictors Xj and Xj' has the same correlation 0.5. See details in Simon et al. (2011).
data(FHT)
data(FHT)
This list
object named "FHT" contains the following data:
a covariate matrix with 50 rows and 100 columns
the distinct failure times
the censoring indicator (status = 1 indicates no censoring and status = 0 indicates right censoring)
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
Journal of Statistical Software, Vol. 33(1), 1-22 Feb 2010
http://www.jstatsoft.org/v33/i01/
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/
data(FHT)
data(FHT)
Produces a coefficient profile plot of the coefficient paths for a
fitted cocktail
object. This function is modified based on the plot
function from the glmnet
package.
## S3 method for class 'cocktail' plot(x, xvar = c("norm", "lambda"), color = FALSE, label = FALSE, ...)
## S3 method for class 'cocktail' plot(x, xvar = c("norm", "lambda"), color = FALSE, label = FALSE, ...)
x |
fitted |
xvar |
what is on the X-axis. |
color |
if |
label |
if |
... |
other graphical parameters to plot |
A coefficient profile plot is produced.
Yi Yang and Hui Zou
Maintainer: Yi Yang <[email protected]>
Yang, Y. and Zou, H. (2013),
"A Cocktail Algorithm for Solving The Elastic Net Penalized Cox's Regression in High Dimensions", Statistics and Its Interface, 6:2, 167-173.
https://github.com/emeryyi/fastcox
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
Journal of Statistical Software, Vol. 33(1), 1-22 Feb 2010
http://www.jstatsoft.org/v33/i01/
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/
data(FHT) m1<-cocktail(x=FHT$x,y=FHT$y,d=FHT$status,alpha=0.5) par(mfrow=c(1,3)) plot(m1) # plots against the L1-norm of the coefficients plot(m1,xvar="lambda",label=TRUE) # plots against the log-lambda sequence plot(m1,color=TRUE)
data(FHT) m1<-cocktail(x=FHT$x,y=FHT$y,d=FHT$status,alpha=0.5) par(mfrow=c(1,3)) plot(m1) # plots against the L1-norm of the coefficients plot(m1,xvar="lambda",label=TRUE) # plots against the log-lambda sequence plot(m1,color=TRUE)
Plots the cross-validation curve, and upper and lower standard deviation
curves, as a function of the lambda
values used. This function is modified based on the plot.cv
function from the glmnet
package.
## S3 method for class 'cv.cocktail' plot(x, sign.lambda, ...)
## S3 method for class 'cv.cocktail' plot(x, sign.lambda, ...)
x |
fitted |
sign.lambda |
either plot against |
... |
other graphical parameters to plot |
A plot is produced.
Yi Yang and Hui Zou
Maintainer: Yi Yang <[email protected]>
Yang, Y. and Zou, H. (2013),
"A Cocktail Algorithm for Solving The Elastic Net Penalized Cox's Regression in High Dimensions", Statistics and Its Interface, 6:2, 167-173.
https://github.com/emeryyi/fastcox
Friedman, J., Hastie, T., and Tibshirani, R. (2010), "Regularization paths for generalized
linear models via coordinate descent," Journal of Statistical Software, 33, 1.
http://www.jstatsoft.org/v33/i01/
Similar to other predict methods, this functions predicts fitted values, link function and more from a fitted cocktail
object. This function is modified based on the predict
function from the glmnet
package.
## S3 method for class 'cocktail' predict(object,newx,s=NULL,type=c("link","response","coefficients","nonzero"),...)
## S3 method for class 'cocktail' predict(object,newx,s=NULL,type=c("link","response","coefficients","nonzero"),...)
object |
fitted |
newx |
matrix of new values for |
s |
value(s) of the penalty parameter |
type |
type of prediction required.
|
... |
Not used. Other arguments to predict. |
s
is the new vector at which predictions are requested. If s
is not in the lambda sequence used for fitting the model, the predict
function will use linear interpolation to make predictions. The new values are interpolated using a fraction of predicted values from both left and right lambda
indices.
The object returned depends on type.
Yi Yang and Hui Zou
Maintainer: Yi Yang <[email protected]>
Yang, Y. and Zou, H. (2013),
"A Cocktail Algorithm for Solving The Elastic Net Penalized Cox's Regression in High Dimensions", Statistics and Its Interface, 6:2, 167-173.
https://github.com/emeryyi/fastcox
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
Journal of Statistical Software, Vol. 33(1), 1-22 Feb 2010
http://www.jstatsoft.org/v33/i01/
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/
coef
method
data(FHT) m1<-cocktail(x=FHT$x,y=FHT$y,d=FHT$status,alpha=0.5) predict(m1,type="nonzero") predict(m1,newx=FHT$x[1:5,],type="response")
data(FHT) m1<-cocktail(x=FHT$x,y=FHT$y,d=FHT$status,alpha=0.5) predict(m1,type="nonzero") predict(m1,newx=FHT$x[1:5,],type="response")
Print a summary of the cocktail path at each step along the path. This function is modified based on the print
function from the glmnet
package.
## S3 method for class 'cocktail' print(x, digits = max(3, getOption("digits") - 3), ...)
## S3 method for class 'cocktail' print(x, digits = max(3, getOption("digits") - 3), ...)
x |
fitted |
digits |
significant digits in printout |
... |
additional print arguments |
The call that produced the cocktail
object is printed, followed by a two-column matrix with columns Df
and Lambda
. The Df
column is the number of nonzero coefficients.
a two-column matrix, the first columns is the number of nonzero coefficients and the second column is Lambda
.
Yi Yang and Hui Zou
Maintainer: Yi Yang <[email protected]>
Yang, Y. and Zou, H. (2013),
"A Cocktail Algorithm for Solving The Elastic Net Penalized Cox's Regression in High Dimensions", Statistics and Its Interface, 6:2, 167-173.
https://github.com/emeryyi/fastcox
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
Journal of Statistical Software, Vol. 33(1), 1-22 Feb 2010
http://www.jstatsoft.org/v33/i01/
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/
data(FHT) m1<-cocktail(x=FHT$x,y=FHT$y,d=FHT$status,alpha=0.5) print(m1)
data(FHT) m1<-cocktail(x=FHT$x,y=FHT$y,d=FHT$status,alpha=0.5) print(m1)