cv.binomial: k-fold cross validation for penalized generalized linear...

Description Usage Arguments Value Note Author(s) References Examples

View source: R/extlasso.R

Description

The function does k-fold cross validation for selecting best value of regularization parameter.

Usage

1
cv.binomial(x,y,k=5,nlambda=50,tau=1,plot=TRUE,errorbars=TRUE)

Arguments

x

x is matrix of order n x p where n is number of observations and p is number of predictor variables. Rows should represent observations and columns should represent predictor variables.

y

y is a vector of response variable of order n x 1.

k

Number of folds for cross validation. Default is k=5.

nlambda

Number of lambda values to be used for cross validation. Default is nlambda=50.

tau

Elastic net parameter, 0 ≤ τ ≤ 1 in elastic net penalty λ\{τ\|β\|_1+(1-τ)\|beta\|_2^2\}. Default tau=1 corresponds to LASSO penalty.

plot

if TRUE, produces a plot of cross validated prediction mean squared errors against lambda. Default is TRUE.

errorbars

If TRUE, error bars are drawn in the plot. Default is TRUE.

Value

Produces a plot and returns a list with following components:

lambda

Value of lambda for which average cross validation error is minimum

pmse

A vector of average cross validation errors for various lambda values

lambdas

A vector of lambda values used in cross validation

se

A vector containing standard errors of cross validation errors

Note

This function need not be called by user. The function is internally called by cv.extlasso function.

Author(s)

B N Mandal and Jun Ma

References

Mandal, B.N. and Jun Ma, (2014). A Jacobi-Armijo Algorithm for LASSO and its Extensions.

Examples

1
2
3
x=matrix(rnorm(100*30),100,30)
y=sample(c(0,1),100,replace=TRUE)
cv.binomial(x,y,k=5)

Example output

$lambda
[1] 0.4457849

$pmse
 [1] 27.14284 26.64648 26.80273 26.64116 26.51991 26.43357 26.63685 27.13989
 [9] 27.85279 28.57448 29.34042 30.21344 31.23429 32.44079 33.77653 35.28006
[17] 36.89213 38.48959 40.26346 42.13201 43.98687 45.89433 47.72207 49.53053
[25] 51.08778 52.92242 54.50583 55.73817 57.19701 58.43471 59.45132 60.21268
[33] 61.13418 61.90444 62.52021 62.93294 63.13702 63.81707 64.08574 64.43716
[41] 64.70204 64.87172 65.00281 65.12737 65.25952 65.38935 65.49979 65.60253
[49] 65.68510 65.73905

$lambdas
 [1] 1.1197611503 0.9313767571 0.7746854438 0.6443552862 0.5359513828
 [6] 0.4457849432 0.3707877655 0.3084078301 0.2565224598 0.2133660885
[11] 0.1774701824 0.1476132682 0.1227793686 0.1021234307 0.0849425698
[16] 0.0706521522 0.0587659005 0.0488793470 0.0406560700 0.0338162461
[21] 0.0281271284 0.0233951264 0.0194592186 0.0161854730 0.0134624901
[26] 0.0111976115 0.0093137676 0.0077468544 0.0064435529 0.0053595138
[31] 0.0044578494 0.0037078777 0.0030840783 0.0025652246 0.0021336609
[36] 0.0017747018 0.0014761327 0.0012277937 0.0010212343 0.0008494257
[41] 0.0007065215 0.0005876590 0.0004887935 0.0004065607 0.0003381625
[46] 0.0002812713 0.0002339513 0.0001945922 0.0001618547 0.0001346249

$se
 [1]  0.5830438  0.5502278  0.5889293  0.5510711  0.5081886  0.5551716
 [7]  0.7440706  0.9899392  1.2770570  1.6137103  2.0028964  2.4069928
[13]  2.9031728  3.4724836  4.0757569  4.7016157  5.3671263  6.0312094
[19]  6.8746564  7.7436307  8.6652512  9.6894495 10.7415124 11.8084759
[25] 12.7151041 14.0011984 15.0454656 15.8458997 16.9221339 17.8369838
[31] 18.6204512 19.1176914 19.8332054 20.4409547 20.8950128 21.1790511
[37] 21.2933812 21.8818363 22.0727488 22.3623944 22.5779449 22.7040309
[43] 22.7974729 22.8981744 23.0021816 23.1070003 23.2005172 23.2856704
[49] 23.3586971 23.3992245

There were 16 warnings (use warnings() to see them)

extlasso documentation built on May 2, 2019, 11:39 a.m.