Nonparametric survival estimates.
Usage
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"),
...
)Arguments
- object
For the
rfsrcmethod: a fittedrfsrcsurvival forest. For the default method: passNULL(or omit) and supplyinterval,censor, anddatainstead.- interval
Character; name of the time-to-event column in
data(default method only).- censor
Character; name of the event-indicator column in
data(1 = event, 0 = censored; default method only).- by
Optional character; name of a grouping column for stratified estimates. For the
rfsrcmethod,bymust be a column inobject$xvar.- data
A
data.framecontaining survival data (default method only).- type
One of
"kaplan"(Kaplan-Meier, default) or"nelson"(Nelson-Aalen cumulative hazard). Default method only.- ...
Value
A gg_survival data.frame with columns time,
surv, cum_haz, lower, upper, n.risk,
and optionally groups when by is supplied.
Details
gg_survival is an S3 generic for generating nonparametric
survival estimates. It dispatches on the class of its first argument:
rfsrcExtracts the response data from the fitted forest and delegates to
kaplan. Use thebyargument to stratify on a predictor stored in the model'sxvarslot.- default
Accepts raw survival data columns via the
interval,censor,by, anddataarguments, delegating to eitherkaplan(default) ornelson.
Examples
## -------- 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)