| survmeans | R Documentation |
For a Cox model (survival::coxph) or an accelerated failure time model (survival::survreg), the
survival curve S(t) of each level of modelterm with pointwise confidence limits, and the median survival
time with its limits.
survmeans(
model,
modelterm,
at = NULL,
times = NULL,
conf_level = 0.95,
data = NULL,
marginal = FALSE
)
## S3 method for class 'pm_survmeans'
autoplot(object, limits = TRUE, ...)
## S3 method for class 'pm_survmeans'
plot(x, ...)
model |
A |
modelterm |
A factor of the model, or an interaction of factors ( |
at |
A named list: levels of the other factors (one each), or values of numeric covariates. |
times |
The times at which to give S(t). Default: |
conf_level |
The confidence level of the limits. |
data |
The data the model was fitted to, when they cannot be found. |
marginal |
Bayesian fits only ( |
object |
A |
limits |
Draw the pointwise limits as bands. |
... |
Not used. |
x |
A |
Each curve is that of one covariate pattern: the level of modelterm, numeric covariates at their means
(as predictmeans), and the other factors at the levels in at (by default their first
level, with a message). A curve averaged over the levels of another factor would need the covariance between
curves; it is not given, so that no limits are approximate. Give the factor in modelterm to see a curve
for each of its levels.
coxph: survival::survfit() with that pattern as newdata (the Breslow or Efron
estimate of the baseline hazard of the fit, and its variance); in a stratified model the strata factor is one
of the pattern (in modelterm or at), and each curve uses the baseline hazard of its stratum.
The curves stop (NA) after the last follow-up time of the data (of the stratum). The median and its
limits are those of quantile() of the curve.
survreg: S(t) = 1 - F((log t - eta) / sigma) for the fitted distribution, with the delta method
over the coefficients and log(sigma); the median is exp(eta + sigma q50). Distributions on the log-time
scale only, and one scale (no strata()).
The limits are on the log survival scale (conf.type = "log", as survfit()'s default), at
conf_level; they are pointwise, not a band for the whole curve.
An object of class pm_survmeans: curves (the levels, time, surv,
conf.low, conf.high), medians (the levels, median, conf.low,
conf.high; NA when the curve does not fall to 0.5) and settings (the pattern of the other
variables, the method). autoplot() draws the curves.
predictmeans for hazard ratios and time ratios between the levels.
library(survival)
lung2 <- na.omit(lung[, c("time", "status", "ph.ecog", "sex", "age")])
lung2$ecog <- factor(lung2$ph.ecog)
lung2$sex <- factor(lung2$sex)
sm <- survmeans(coxph(Surv(time, status) ~ ecog + sex + age, data = lung2), "ecog",
at = list(sex = "2"))
sm$medians
ggplot2::autoplot(sm)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.