cv.poisson: 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.poisson(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(1:5),100,replace=TRUE)
cv.poisson(x,y,k=5)

Example output

$lambda
[1] 2.662834

$pmse
 [1] 62.14864 50.78204 23.22185 17.92231 18.14896 18.49697 18.92505 19.24828
 [9] 19.61793 20.02093 20.33679 20.65856 20.95473 21.18042 21.39074 21.61293
[17] 21.86580 22.13394 22.41571 22.68411 22.92801 23.14868 23.35107 23.53654
[25] 23.69234 23.82567 23.94185 24.03491 24.11894 24.18782 24.24545 24.29317
[33] 24.33237 24.36713 24.39625 24.41956 24.43759 24.45607 24.46913 24.48140
[41] 24.49124 24.49887 24.50487 24.51072 24.51512 24.51957 24.52336 24.52590
[49] 24.52830 24.53052

$lambdas
 [1] 4.6274752675 3.8489662791 3.2014307072 2.6628340779 2.2148489145
 [6] 1.8422310855 1.5323010749 1.2745125206 1.0600933404 0.8817472345
[11] 0.7334054050 0.6100200454 0.5073925734 0.4220307603 0.3510298967
[16] 0.2919739506 0.2428533542 0.2019966218 0.1680134719 0.1397475190
[21] 0.1162369234 0.0966816617 0.0804163035 0.0668873679 0.0556344894
[26] 0.0462747527 0.0384896628 0.0320143071 0.0266283408 0.0221484891
[31] 0.0184223109 0.0153230107 0.0127451252 0.0106009334 0.0088174723
[36] 0.0073340540 0.0061002005 0.0050739257 0.0042203076 0.0035102990
[41] 0.0029197395 0.0024285335 0.0020199662 0.0016801347 0.0013974752
[46] 0.0011623692 0.0009668166 0.0008041630 0.0006688737 0.0005563449

$se
 [1] 14.0841887 13.7669825  6.7583945  1.5586261  1.3384812  1.1659317
 [7]  1.0186622  0.9342393  0.9764979  1.0237676  1.0350815  1.0469986
[13]  1.0871245  1.1195707  1.1640097  1.2215370  1.2865315  1.3485635
[19]  1.4122220  1.4648988  1.5116326  1.5528446  1.5858501  1.6105982
[25]  1.6329525  1.6515026  1.6669399  1.6800329  1.6918715  1.7010997
[31]  1.7093652  1.7156401  1.7214154  1.7270151  1.7308176  1.7339229
[37]  1.7346868  1.7385865  1.7404312  1.7425325  1.7433468  1.7446174
[43]  1.7453343  1.7464623  1.7468013  1.7477350  1.7478867  1.7482504
[49]  1.7486269  1.7490184

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

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