plot.pcoxtimecv: Plot solution path for pcoxtimecv

View source: R/pcoxtimeplots.R

plot.pcoxtimecvR Documentation

Plot solution path for pcoxtimecv

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 'pcoxtimecv'
plot(
  x,
  ...,
  type = c("cve", "fit"),
  xvar = c("lambda", "l1"),
  show_nzero = FALSE,
  seed = 1234,
  geom = c("point", "line"),
  g.size = 0.2,
  g.col = "red",
  bar.col = g.col,
  scales = "free_x",
  show_min_cve = TRUE
)

Arguments

x

fitted pcoxtimecv 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 pcoxtimecv.

geom

geom ("point" or "line") for partial likelihood

g.size

size specification for points/lines

g.col

colour specification for points/lines

bar.col

colour specification for error bars

scales

should scales be "fixed", "free", "free_x" or "free_y"?

show_min_cve

whether or not to show the alpha which gives minimum cross-validation error. Ignored if a single alpha is specified. This replaced "Optimal" in the version 1.01.1 and below.

Details

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

Value

a ggplot object.

Examples


library(ggplot2)
# Time-varying covariates
## Not run: 
data(heart, package="survival")
# Using a vector of alphas = (0.8, 1)
cv1 <- pcoxtimecv(Surv(start, stop, event) ~ age + year + surgery + transplant
	, data = heart
	, alphas = c(0.8, 1)
	, refit = TRUE
	, lamfract = 0.6
	, seed = 1234
)
# Plot cross-validation curves
plot(cv1, type = "cve")

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

## End(Not run)

pcoxtime documentation built on May 13, 2022, 1:05 a.m.