plot.cv.glintnet | R Documentation |
Plots the cross-validation curve, and upper and lower standard deviation
curves, as a function of the lambda
values used.
Plots the cross-validation curve, and upper and lower standard deviation
curves, as a function of the lambda
values used.
## S3 method for class 'cv.glintnet'
plot(x, sign.lambda = -1, ...)
## S3 method for class 'cv.grpnet'
plot(x, sign.lambda = -1, ...)
x |
fitted |
sign.lambda |
Either plot against |
... |
Other graphical parameters |
A plot is produced, and nothing is returned.
A plot is produced, and nothing is returned.
James Yang, Trevor Hastie, and Balasubramanian Narasimhan
Maintainer:
Trevor Hastie hastie@stanford.edu
Yang, James and Hastie, Trevor. (2024) A Fast and Scalable Pathwise-Solver for Group Lasso
and Elastic Net Penalized Regression via Block-Coordinate Descent. arXiv \Sexpr[results=rd]{tools:::Rd_expr_doi("10.48550/arXiv.2405.08631")}.
Adelie Python user guide https://jamesyang007.github.io/adelie/
grpnet
and cv.grpnet
.
set.seed(0)
n=500
d_cont = 5 # number of continuous features
d_disc = 5 # number of categorical features
Z_cont = matrix(rnorm(n*d_cont), n, d_cont)
levels = sample(2:5,d_disc, replace = TRUE)
Z_disc = matrix(0,n,d_disc)
for(i in seq(d_disc))Z_disc[,i] = sample(0:(levels[i]-1),n,replace=TRUE)
Z = cbind(Z_cont,Z_disc)
levels = c(rep(1,d_cont),levels)
xmat = model.matrix(~Z_cont[,1]*factor(Z_disc[,2]))
nc=ncol(xmat)
beta = rnorm(nc)
y = xmat%*%beta+rnorm(n)*1.5
cvfit <- cv.glintnet(Z, glm.gaussian(y), levels=levels, intr_keys = 1)
plot(cvfit)
set.seed(1010)
n = 1000
p = 100
nzc = trunc(p/10)
x = matrix(rnorm(n * p), n, p)
beta = rnorm(nzc)
fx = (x[, seq(nzc)] %*% beta)
eps = rnorm(n) * 5
y = drop(fx + eps)
px = exp(fx)
px = px/(1 + px)
ly = rbinom(n = length(px), prob = px, size = 1)
cvob1 = cv.grpnet(x, glm.gaussian(y))
plot(cvob1)
title("Gaussian Family", line = 2.5)
frame()
set.seed(1011)
cvob2 = cv.grpnet(x, glm.binomial(ly))
plot(cvob2)
title("Binomial Family", line = 2.5)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.