plot.glmnetsurvcv: Plot solution path for glmnetsurvcv

View source: R/postsurvplots.R

plot.glmnetsurvcvR Documentation

Plot solution path for glmnetsurvcv

Description

Plots the cross-validation curve, and upper and lower standard deviation curves, as a function of the optimal lambdas. Also, plots the solution path as a function of optimal lambdas (or randomly picked fold, if refit = FALSE) or l1-norm.

Usage

## S3 method for class 'glmnetsurvcv'
plot(
  x,
  ...,
  type = c("cve", "fit"),
  xvar = c("lambda", "l1"),
  show_nzero = FALSE,
  seed = 1234
)

Arguments

x

fitted glmnetsurvcv object.

...

for future implementations

type

which plot to return. type = "cve" (default) return a cross-validation curve and type = "fit" returns coefficient profiles (solution path). See details.

xvar

only if type = "fit". Plot coefficients a function of either lambda (xvar = "lambda") or l1-norm (xvar = "l1").

show_nzero

logical. Whether to show number of nonzero coefficients on the plot. Default is show_nzero = FALSE. Still experimental for type = "cve".

seed

random number generator. Important if refit = FALSE in glmnetsurvcv.

Details

To plot solution path corresponding to optimal alpha and lambda, set refit = TRUE in glmnetsurvcv. The plot is a ggplot object, hence can be be customized further.

Value

a ggplot object.

Examples


library(ggplot2)
data(veteran, package="survival")
# Using a vector of alphas = (0.8, 1)
cv1 <- glmnetsurvcv(Surv(time, status) ~ factor(trt) + karno + diagtime + age + prior
	, data = veteran
	, alpha = c(0.8, 1)
	, refit = TRUE
)
# Plot cross-validation curves
plot(cv1, type = "cve")

# Plot
plot(cv1, type = "fit")


CYGUBICKO/glmnetpostsurv documentation built on Sept. 1, 2022, 7:26 p.m.