plot.cv.glmnetr: Plot cross-validation deviances, or model coefficients.

View source: R/plot.cv.glmnetr_250503.R

plot.cv.glmnetrR Documentation

Plot cross-validation deviances, or model coefficients.

Description

By default, with coefs=FALSE, plots the average deviances as function of lambda and gamma, and also indicates the gamma and lambda which minimize deviance for the lasso, elastic net or ridge model. Optionally, with coefs=TRUE, plots the relaxed lasso coefficients.

Usage

## S3 method for class 'cv.glmnetr'
plot(
  x,
  type = "lasso",
  alpha = NULL,
  gamma = NULL,
  lambda.lo = NULL,
  plup = 0,
  title = NULL,
  coefs = FALSE,
  comment = TRUE,
  lty = 1,
  track = 0,
  ...
)

Arguments

x

a nested.glmnetr() output object.

type

one of c("lasso", "elastic", "ridge") to plot the deviance curves of the respective model fit. Default is "lasso" for tuned relaxed lasso.

alpha

A specific value of alpha for plotting. Used only when type is set to "elastic". Specifies which alpha is to be used for deviance plots. Default is "alpha.min", else must be an element of the alpha vector used in running the elastic net model. This can be reviewed using summary(fit) where fit is a nested.glmnetr() output object. Note, alpha is 1 for the lasso model and alpha is 0 for the ridge model.

gamma

a specific level of gamma for plotting. By default gamma.min will be used.

lambda.lo

a lower limit of lambda when plotting.

plup

an indicator to plot the upper 95 percent two-sided confidence limits.

title

a title for the plot.

coefs

default of FALSE plots deviances, option of TRUE plots coefficients.

comment

default of TRUE to write to console information on lambda and gamma selected for output. FALSE will suppress this write to console.

lty

line type for the cross validated deviances. Default is 1.

track

2 to track progress by printing to console, 0 (default) to not track.

...

Additional arguments passed to the plot function.

Value

This program returns a plot to the graphics window, and may provide some numerical information to the R Console. If gamma is not specified, then then the gamma.min from the deviance minimizing (lambda.min, gamma.min) pair will be used, and the corresponding lambda.min will be indicated by a vertical line, and the lambda minimizing deviance under the restricted set of models where gamma=0 will be indicated by a second vertical line.

See Also

plot.glmnetr , plot.nested.glmnetr


glmnetr documentation built on June 8, 2025, 10:12 a.m.