plot.glmnetr: Plot the relaxed lasso coefficients.

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

plot.glmnetrR Documentation

Plot the relaxed lasso coefficients.

Description

Plot the relaxed lasso, elastic net or ridge model coefficients from a nested.glmnetr() output object. One may specify a value for gamma. If gamma is unspecified (NULL), then the plot will be for the gamma which minimizes loss.

Usage

## S3 method for class 'glmnetr'
plot(
  x,
  type = "lasso",
  alpha = NULL,
  gamma = NULL,
  lambda.lo = NULL,
  title = NULL,
  comment = TRUE,
  ...
)

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".

alpha

A specific level of alpha for plotting. By default alpha.min will be used such that the triplet (alpha.min, gamma.min, lambda.min) minimizes the model deviance.

gamma

A specific level of gamma for plotting. By default gamma.min will be used such that the pair (gamma.min, lambda.min) minimzes the model deviance.

lambda.lo

A lower limit of lambda for plotting.

title

A title for the plot

comment

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

...

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 the gamma.min from the deviance minimizing (lambda.min, gamma.min) pair will be used, and the minimizing lambda.min will be indicated by a vertical line. Also, if one specifies gamma=0, the lambda which minimizes deviance for the restricted set of models where gamma=0 will indicated by a vertical line.

See Also

plot.cv.glmnetr , plot.nested.glmnetr

Examples


set.seed(82545037)
sim.data=glmnetr.simdata(nrows=200, ncols=100, beta=NULL)
xs=sim.data$xs 
yt=sim.data$yt
yg=sim.data$yt
event=sim.data$event
glmnetr.fit = nested.glmnetr(xs, start=NULL, yg, event=event, family="gaussian",
  resample=0, folds_n=4)
plot(glmnetr.fit, type="lasso")



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