| gg_survival | R Documentation |
Nonparametric survival estimates.
gg_survival(
object = NULL,
interval = NULL,
censor = NULL,
by = NULL,
data = NULL,
type = c("kaplan", "nelson"),
...
)
## S3 method for class 'rfsrc'
gg_survival(
object,
interval = NULL,
censor = NULL,
by = NULL,
data = NULL,
type = c("kaplan", "nelson"),
...
)
## Default S3 method:
gg_survival(
object = NULL,
interval = NULL,
censor = NULL,
by = NULL,
data = NULL,
type = c("kaplan", "nelson"),
...
)
object |
For the |
interval |
Character; name of the time-to-event column in |
censor |
Character; name of the event-indicator column in |
by |
Optional character; name of a grouping column for stratified
estimates. For the |
data |
A |
type |
One of |
... |
Additional arguments passed to |
Comparing the forest's ensemble survival curve to the marginal
Kaplan-Meier baseline is a quick sanity check: if they diverge the forest
has found structure the predictors carry; if they track each other closely
the predictors may add little. gg_survival computes
the nonparametric baseline – the Kaplan-Meier or Nelson-Aalen estimate –
so you can place it on the same canvas as the forest predictions from
gg_rfsrc.
gg_survival is an S3 generic that dispatches on the class of its
first argument:
rfsrcExtracts the outcome columns from the fitted
forest's $yvar slot (time in column 1, event indicator in
column 2) and delegates to kaplan. Use by to
stratify on a predictor from $xvar: you get one
Kaplan-Meier curve per group, ready to compare against the forest's
group-specific ensemble curves.
Accepts raw survival columns directly via
interval, censor, and data. Delegates to
kaplan (the default) or nelson depending
on type.
A gg_survival data.frame with columns time,
surv, cum_haz, lower, upper, n.risk,
and optionally groups when by is supplied.
Survival estimation is randomForestSRC-only; randomForest
has no survival forest, so no randomForest method exists.
kaplan nelson
plot.gg_survival
## -------- pbc data (default method, raw data columns)
data(pbc, package = "randomForestSRC")
pbc$time <- pbc$days / 364.25
gg_dta <- gg_survival(interval = "time", censor = "status", data = pbc)
plot(gg_dta, error = "none")
# Stratified
gg_dta <- gg_survival(
interval = "time", censor = "status",
data = pbc, by = "treatment"
)
plot(gg_dta)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.