cv.compare {grpnet}R Documentation

Compare Multiple cv.grpnet Solutions

Description

Creates a plot (default) or returns a data frame (otherwise) that compares the cross-validation error for multiple cv.grpnet fits.

Usage

cv.compare(x,
           s = c("lambda.1se", "lambda.min"), 
           plot = TRUE, 
           at = 1:length(x),
           nse = 1, 
           point.col = "red", 
           line.col = "gray", 
           lwd = 2, 
           bwd = 0.02,
           labels = NULL,
           xlim = NULL,
           ylim = NULL,
           xlab = NULL,
           ylab = NULL,
           ...)

Arguments

x

a single cv.grpnet object or a list of cv.grpnet objects.

s

the tuning parameter value at which to plot results (if x is a list).

plot

switch controlling whether a plot is produced (default) versus data frame.

at

x-axis coordinates for plotting the cv error for each solution.

nse

number of standard errors to use for error bars in plot.

point.col

color for point used to plot the average of the cv error.

line.col

color for lines used to plot the standard error for the cv error.

lwd

width of lines used to plot the standard error for the cv error.

bwd

width of standard error bars in terms of proportion of range(x).

labels

labels for x-axis tick marks. Defaults to names(x).

xlim

axis limits for abscissa (x-axis)

ylim

axis limits for ordinate (y-axis)

xlab

axis label for abscissa (x-axis)

ylab

axis label for ordinate (y-axis)

...

additional arguments passed to plotting functions.

Details

Default behavior creates a plot that displays the mean cv error +/- 1 se for each of the requested solutions.

If the input x is a single cv.grpnet object, then the function plots the lambda.min and lambda.1se solutions.

If the input x is a list of cv.grpnet objects, then the function plots either the lambda.min or the lambda.1se solution (controlled by s argument) for all of the input models.

Value

When plot = TRUE, there is no return value (it produces a plot)

When plot = FALSE, a data.frame is returned with the mean cv error (and se) for each solution

Author(s)

Nathaniel E. Helwig <helwig@umn.edu>

References

Helwig, N. E. (2024). Versatile descent algorithms for group regularization and variable selection in generalized linear models. Journal of Computational and Graphical Statistics. doi:10.1080/10618600.2024.2362232

See Also

plot.cv.grpnet for plotting cv error path (for all lambdas)

plot.grpnet for plotting regularization path (for single lambda)

Examples

# load data
data(auto)

# LASSO penalty
set.seed(1)
mod1 <- cv.grpnet(mpg ~ ., data = auto, nfolds = 5, alpha = 1)

# MCP penalty
set.seed(1)
mod2 <- cv.grpnet(mpg ~ ., data = auto, nfolds = 5, alpha = 1, penaly = "MCP")

# SCAD penalty
set.seed(1)
mod3 <- cv.grpnet(mpg ~ ., data = auto, nfolds = 5, alpha = 1, penaly = "SCAD")

# compare lambda.min and lambda.1se for mod1
cv.compare(mod1)

# compare lambda.1se for mod1, mod2, mod3
cv.compare(x = list(mod1, mod2, mod3), labels = c("LASSO", "MCP", "SCAD"))

[Package grpnet version 0.5 Index]