The hardware and bandwidth for this mirror is donated by METANET, the Webhosting and Full Service-Cloud Provider.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]metanet.ch.
singleEventSurvival() supports non-parametric,
semi-parametric, and parametric survival estimators through a common
interface. This vignette shows how to compare those models once a
survival dataset has already been prepared from Eunomia.
All examples below assume you already created a survival dataset with
the internal addCohortSurvival() helper and included age
and gender columns.
Supported values for model are:
"km""cox""weibull""exponential""lognormal""loglogistic"All of them return the same high-level structure: a named list with
data and summary per stratum, plus
overall.
coxFit <- singleEventSurvival(
survivalData = survivalData,
timeScale = "days",
model = "cox",
covariates = c("age_years")
)
coxFit[["overall"]]$summary
head(coxFit[["overall"]]$data)The Cox path uses covariates when fitting the model, but the returned object is still survival-oriented. It does not expose regression coefficients or hazard ratios.
weibullFit <- singleEventSurvival(
survivalData = survivalData,
timeScale = "days",
model = "weibull",
covariates = c("age_years")
)
lognormalFit <- singleEventSurvival(
survivalData = survivalData,
timeScale = "days",
model = "lognormal",
covariates = c("age_years")
)
weibullFit[["overall"]]$summary
lognormalFit[["overall"]]$summaryParametric models also return a data table with
estimated survival, hazard, and cumulative hazard evaluated on the
observed event-time grid.
One practical way to compare models is to extract the same summary fields from each fit.
modelNames <- c("km", "cox", "weibull", "lognormal")
fits <- lapply(modelNames, function(modelName) {
singleEventSurvival(
survivalData = survivalData,
timeScale = "days",
model = modelName,
covariates = if (modelName == "km") NULL else c("age_years")
)
})
names(fits) <- modelNames
comparison <- data.frame(
model = names(fits),
medianSurvival = vapply(fits, function(x) x[["overall"]]$summary$medianSurvival, numeric(1)),
meanSurvival = vapply(fits, function(x) x[["overall"]]$summary$meanSurvival, numeric(1)),
stringsAsFactors = FALSE
)
comparisonstrata accepts "gender" and
"age_group". When both are supplied, the package fits them
separately, not as joint interaction strata.
stratifiedFit <- singleEventSurvival(
survivalData = survivalData,
timeScale = "days",
model = "weibull",
covariates = c("age_years"),
strata = c("gender", "age_group"),
ageBreaks = list(c(18, 49), c(50, 64), c(65, Inf))
)
names(stratifiedFit)
stratifiedFit[["gender=Female"]]$summary
stratifiedFit[["age_group=65+"]]$summary
stratifiedFit$logrank_test_gender
stratifiedFit$logrank_test_age_groupEach fitted entry can be plotted from its data
component.
"km" for descriptive, assumption-light
summaries."cox" when covariates matter but you still want a
survival-curve summary.The advanced usage pattern is mostly about choosing the right
model value and then extracting comparable summaries from
the returned list structure. ```
This vignette covered:
For getting started, see the “Getting Started” vignette.
These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.