View source: R/pcoxtimeplots.R
plot.pcoxtimecv | R Documentation |
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.
## 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
)
x |
fitted |
... |
for future implementations |
type |
which plot to return. |
xvar |
only if |
show_nzero |
logical. Whether to show number of nonzero coefficients on the plot. Default is |
seed |
random number generator. Important if |
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 |
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.
a ggplot
object.
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.