cv.cocktail: Cross-validation for cocktail

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

View source: R/cv.cocktail.R

Description

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.

Usage

1
cv.cocktail(x,y,d,lambda=NULL,nfolds=5,foldid,...)

Arguments

x

matrix of predictors, of dimension N*p; each row is an observation vector.

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 NULL, and cocktail chooses its own sequence.

nfolds

number of folds - default is 5. Although nfolds can be as large as the sample size (leave-one-out CV), it is not recommended for large datasets. Smallest value allowable is nfolds=3.

foldid

an optional vector of values between 1 and nfold identifying what fold each observation is in. If supplied, nfold can be missing.

...

other arguments that can be passed to cocktail.

Details

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.

Value

an object of class cv.cocktail is returned, which is a list with the ingredients of the cross-validation fit.

lambda

the values of lambda used in the fits.

cvm

the mean cross-validated error - a vector of length length(lambda).

cvsd

estimate of standard error of cvm.

cvup

upper curve = cvm+cvsd.

cvlo

lower curve = cvm-cvsd.

nzero

number of non-zero coefficients at each lambda.

name

a text string indicating partial likelihood (for plotting purposes).

cocktail.fit

a fitted cocktail object for the full data.

lambda.min

The optimal value of lambda that gives minimum cross validation error cvm.

lambda.1se

The largest value of lambda such that error is within 1 standard error of the minimum.

Author(s)

Yi Yang and Hui Zou
Maintainer: Yi Yang <yi.yang6@mcgill.ca>

References

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/

See Also

cocktail, plot.cv.cocktail.

Examples

1
2
3
4
data(FHT)
cv1<-cv.cocktail(x=FHT$x[,1:10],y=FHT$y,d=FHT$status,alpha=0.5,nfolds=3)
cv1
plot(cv1)

Example output

Loading required package: Matrix
$lambda
  [1] 5.228104e-01 4.763654e-01 4.340464e-01 3.954869e-01 3.603529e-01
  [6] 3.283402e-01 2.991713e-01 2.725938e-01 2.483773e-01 2.263121e-01
 [11] 2.062072e-01 1.878883e-01 1.711968e-01 1.559882e-01 1.421306e-01
 [16] 1.295041e-01 1.179993e-01 1.075166e-01 9.796512e-02 8.926217e-02
 [21] 8.133237e-02 7.410702e-02 6.752356e-02 6.152495e-02 5.605925e-02
 [26] 5.107910e-02 4.654137e-02 4.240676e-02 3.863946e-02 3.520684e-02
 [31] 3.207916e-02 2.922934e-02 2.663268e-02 2.426671e-02 2.211092e-02
 [36] 2.014665e-02 1.835688e-02 1.672610e-02 1.524020e-02 1.388630e-02
 [41] 1.265268e-02 1.152865e-02 1.050448e-02 9.571290e-03 8.721003e-03
 [46] 7.946253e-03 7.240330e-03 6.597119e-03 6.011049e-03 5.477044e-03
 [51] 4.990479e-03 4.547138e-03 4.143183e-03 3.775114e-03 3.439743e-03
 [56] 3.134166e-03 2.855735e-03 2.602040e-03 2.370882e-03 2.160259e-03
 [61] 1.968348e-03 1.793485e-03 1.634157e-03 1.488983e-03 1.356706e-03
 [66] 1.236180e-03 1.126361e-03 1.026298e-03 9.351246e-04 8.520507e-04
 [71] 7.763569e-04 7.073875e-04 6.445451e-04 5.872855e-04 5.351127e-04
 [76] 4.875747e-04 4.442599e-04 4.047931e-04 3.688324e-04 3.360663e-04
 [81] 3.062111e-04 2.790082e-04 2.542219e-04 2.316375e-04 2.110595e-04
 [86] 1.923095e-04 1.752253e-04 1.596587e-04 1.454751e-04 1.325515e-04
 [91] 1.207760e-04 1.100466e-04 1.002703e-04 9.136260e-05 8.324620e-05
 [96] 7.585084e-05 6.911246e-05 6.297270e-05 5.737838e-05 5.228104e-05

$cvm
  [1] 7.988034 8.001951 8.011603 8.021837 8.012530 8.006864 8.004877 7.996505
  [9] 7.988101 7.953593 7.920563 7.845395 7.777487 7.716275 7.658313 7.604863
 [17] 7.554429 7.498828 7.446816 7.399437 7.347498 7.301799 7.261896 7.227928
 [25] 7.199561 7.178166 7.163354 7.152179 7.142928 7.134919 7.130877 7.132719
 [33] 7.140008 7.153254 7.171051 7.192521 7.217223 7.244879 7.278302 7.315247
 [41] 7.354929 7.395963 7.438348 7.482634 7.526644 7.571226 7.616295 7.660807
 [49] 7.704474 7.748301 7.790353 7.831609 7.872294 7.911219 7.948360 7.984770
 [57] 8.018421 8.051096 8.081975 8.111566 8.138783 8.164794 8.188947 8.211957
 [65] 8.233456 8.253066 8.269746 8.287938 8.305249 8.319147 8.332370 8.342494
 [73] 8.356300 8.367304 8.376278 8.385870 8.394783 8.400613 8.409897 8.415067
 [81] 8.420286 8.425524 8.431414 8.436616 8.441782 8.443247 8.448431 8.449900
 [89] 8.455076 8.456539 8.460786 8.462233 8.463677 8.465121 8.466564 8.468004
 [97] 8.469441 8.470874 8.472303 8.473725

$cvsd
  [1] 0.6935363 0.7053006 0.7166984 0.7247742 0.7000575 0.6717964 0.6447913
  [8] 0.6193956 0.6090145 0.6165201 0.6261189 0.6491557 0.6776203 0.7071999
 [15] 0.7350268 0.7604401 0.7831095 0.7910779 0.7968669 0.8022367 0.8118337
 [22] 0.8202156 0.8268783 0.8321305 0.8367071 0.8394284 0.8403013 0.8399029
 [29] 0.8367117 0.8275688 0.8166601 0.8047574 0.7917537 0.7777477 0.7628224
 [36] 0.7475200 0.7317526 0.7159345 0.7033385 0.6928289 0.6825653 0.6726859
 [43] 0.6629450 0.6538107 0.6453698 0.6377229 0.6312570 0.6255475 0.6206640
 [50] 0.6170169 0.6145697 0.6130963 0.6122433 0.6127379 0.6138564 0.6153601
 [57] 0.6179932 0.6209896 0.6243917 0.6283667 0.6320129 0.6361944 0.6403695
 [64] 0.6444673 0.6487126 0.6527402 0.6575600 0.6610503 0.6647548 0.6693714
 [71] 0.6712912 0.6747638 0.6789607 0.6811446 0.6838988 0.6871646 0.6899810
 [78] 0.6919825 0.6933511 0.6949333 0.6965453 0.6981759 0.7002827 0.7019159
 [85] 0.7035494 0.7037893 0.7054451 0.7056904 0.7073615 0.7076101 0.7089403
 [92] 0.7091903 0.7094432 0.7097001 0.7099611 0.7102259 0.7104947 0.7107670
 [99] 0.7110428 0.7113218

$cvup
  [1] 8.681570 8.707251 8.728302 8.746611 8.712587 8.678660 8.649668 8.615900
  [9] 8.597116 8.570113 8.546682 8.494550 8.455108 8.423474 8.393340 8.365303
 [17] 8.337539 8.289906 8.243683 8.201673 8.159332 8.122014 8.088774 8.060058
 [25] 8.036268 8.017594 8.003655 7.992082 7.979640 7.962488 7.947537 7.937476
 [33] 7.931761 7.931001 7.933874 7.940040 7.948976 7.960814 7.981641 8.008076
 [41] 8.037494 8.068649 8.101293 8.136445 8.172014 8.208948 8.247552 8.286354
 [49] 8.325138 8.365318 8.404923 8.444705 8.484537 8.523957 8.562217 8.600130
 [57] 8.636414 8.672085 8.706367 8.739932 8.770796 8.800989 8.829317 8.856425
 [65] 8.882168 8.905806 8.927306 8.948988 8.970004 8.988519 9.003662 9.017258
 [73] 9.035261 9.048448 9.060177 9.073035 9.084764 9.092595 9.103248 9.110000
 [81] 9.116831 9.123700 9.131697 9.138532 9.145331 9.147037 9.153876 9.155591
 [89] 9.162438 9.164149 9.169726 9.171423 9.173121 9.174821 9.176525 9.178230
 [97] 9.179936 9.181642 9.183346 9.185047

$cvlo
  [1] 7.294497 7.296650 7.294905 7.297062 7.312472 7.335067 7.360086 7.377109
  [9] 7.379087 7.337073 7.294444 7.196239 7.099867 7.009075 6.923286 6.844422
 [17] 6.771320 6.707750 6.649949 6.597200 6.535665 6.481583 6.435018 6.395797
 [25] 6.362854 6.338737 6.323053 6.312276 6.306216 6.307350 6.314217 6.327961
 [33] 6.348254 6.375506 6.408229 6.445001 6.485470 6.528945 6.574964 6.622419
 [41] 6.672364 6.723277 6.775403 6.828824 6.881274 6.933503 6.985037 7.035259
 [49] 7.083810 7.131284 7.175783 7.218513 7.260051 7.298481 7.334504 7.369410
 [57] 7.400427 7.430106 7.457584 7.483199 7.506770 7.528600 7.548578 7.567490
 [65] 7.584743 7.600326 7.612186 7.626888 7.640494 7.649776 7.661079 7.667731
 [73] 7.677339 7.686159 7.692379 7.698706 7.704801 7.708630 7.716546 7.720133
 [81] 7.723740 7.727349 7.731132 7.734700 7.738233 7.739458 7.742985 7.744210
 [89] 7.747715 7.748929 7.751846 7.753043 7.754234 7.755421 7.756602 7.757778
 [97] 7.758947 7.760107 7.761260 7.762404

$nzero
 s0  s1  s2  s3  s4  s5  s6  s7  s8  s9 s10 s11 s12 s13 s14 s15 s16 s17 s18 s19 
  0   2   2   2   2   2   4   4   4   5   5   5   6   6   6   6   7   7   7   7 
s20 s21 s22 s23 s24 s25 s26 s27 s28 s29 s30 s31 s32 s33 s34 s35 s36 s37 s38 s39 
  7   7   7   7   7   7   7   8   8   8   8   9   9   9   9  10  10  10  10  10 
s40 s41 s42 s43 s44 s45 s46 s47 s48 s49 s50 s51 s52 s53 s54 s55 s56 s57 s58 s59 
 10  10  10  10  10  10  10  10  10  10  10  10  10  10  10  10  10  10  10  10 
s60 s61 s62 s63 s64 s65 s66 s67 s68 s69 s70 s71 s72 s73 s74 s75 s76 s77 s78 s79 
 10  10  10  10  10  10  10  10  10  10  10  10  10  10  10  10  10  10  10  10 
s80 s81 s82 s83 s84 s85 s86 s87 s88 s89 s90 s91 s92 s93 s94 s95 s96 s97 s98 s99 
 10  10  10  10  10  10  10  10  10  10  10  10  10  10  10  10  10  10  10  10 

$name
[1] "Partial-Likelihood Deviance"

$cocktail.fit

Call:  cocktail(x = x, y = y, d = d, lambda = lambda, alpha = 0.5) 

       Df    Lambda
  [1,]  0 5.228e-01
  [2,]  2 4.764e-01
  [3,]  2 4.340e-01
  [4,]  2 3.955e-01
  [5,]  2 3.604e-01
  [6,]  2 3.283e-01
  [7,]  4 2.992e-01
  [8,]  4 2.726e-01
  [9,]  4 2.484e-01
 [10,]  5 2.263e-01
 [11,]  5 2.062e-01
 [12,]  5 1.879e-01
 [13,]  6 1.712e-01
 [14,]  6 1.560e-01
 [15,]  6 1.421e-01
 [16,]  6 1.295e-01
 [17,]  7 1.180e-01
 [18,]  7 1.075e-01
 [19,]  7 9.797e-02
 [20,]  7 8.926e-02
 [21,]  7 8.133e-02
 [22,]  7 7.411e-02
 [23,]  7 6.752e-02
 [24,]  7 6.152e-02
 [25,]  7 5.606e-02
 [26,]  7 5.108e-02
 [27,]  7 4.654e-02
 [28,]  8 4.241e-02
 [29,]  8 3.864e-02
 [30,]  8 3.521e-02
 [31,]  8 3.208e-02
 [32,]  9 2.923e-02
 [33,]  9 2.663e-02
 [34,]  9 2.427e-02
 [35,]  9 2.211e-02
 [36,] 10 2.015e-02
 [37,] 10 1.836e-02
 [38,] 10 1.673e-02
 [39,] 10 1.524e-02
 [40,] 10 1.389e-02
 [41,] 10 1.265e-02
 [42,] 10 1.153e-02
 [43,] 10 1.050e-02
 [44,] 10 9.571e-03
 [45,] 10 8.721e-03
 [46,] 10 7.946e-03
 [47,] 10 7.240e-03
 [48,] 10 6.597e-03
 [49,] 10 6.011e-03
 [50,] 10 5.477e-03
 [51,] 10 4.990e-03
 [52,] 10 4.547e-03
 [53,] 10 4.143e-03
 [54,] 10 3.775e-03
 [55,] 10 3.440e-03
 [56,] 10 3.134e-03
 [57,] 10 2.856e-03
 [58,] 10 2.602e-03
 [59,] 10 2.371e-03
 [60,] 10 2.160e-03
 [61,] 10 1.968e-03
 [62,] 10 1.793e-03
 [63,] 10 1.634e-03
 [64,] 10 1.489e-03
 [65,] 10 1.357e-03
 [66,] 10 1.236e-03
 [67,] 10 1.126e-03
 [68,] 10 1.026e-03
 [69,] 10 9.351e-04
 [70,] 10 8.521e-04
 [71,] 10 7.764e-04
 [72,] 10 7.074e-04
 [73,] 10 6.445e-04
 [74,] 10 5.873e-04
 [75,] 10 5.351e-04
 [76,] 10 4.876e-04
 [77,] 10 4.443e-04
 [78,] 10 4.048e-04
 [79,] 10 3.688e-04
 [80,] 10 3.361e-04
 [81,] 10 3.062e-04
 [82,] 10 2.790e-04
 [83,] 10 2.542e-04
 [84,] 10 2.316e-04
 [85,] 10 2.111e-04
 [86,] 10 1.923e-04
 [87,] 10 1.752e-04
 [88,] 10 1.597e-04
 [89,] 10 1.455e-04
 [90,] 10 1.326e-04
 [91,] 10 1.208e-04
 [92,] 10 1.100e-04
 [93,] 10 1.003e-04
 [94,] 10 9.136e-05
 [95,] 10 8.325e-05
 [96,] 10 7.585e-05
 [97,] 10 6.911e-05
 [98,] 10 6.297e-05
 [99,] 10 5.738e-05
[100,] 10 5.228e-05

$lambda.min
[1] 0.03207916

$lambda.1se
[1] 0.2062072

attr(,"class")
[1] "cv.cocktail"

fastcox documentation built on May 2, 2019, 10:25 a.m.

Related to cv.cocktail in fastcox...