plot_survival {survextrap} | R Documentation |
Plot survival curves from a survextrap model
Description
Plot survival curves from a survextrap
model. This
function is intended as a quick check of a fitted model, so it
deliberately has limited options for customisation. The data
behind these plots can be extracted with survival
into a tidy data frame to enable custom plots to be constructed
with ggplot2. See the case study vignette for some examples.
Usage
plot_survival(
x,
newdata = NULL,
t = NULL,
tmax = NULL,
km = NULL,
niter = NULL,
newdata0 = NULL,
wane_period = NULL,
wane_nt = 10,
ci = NULL,
xlab = "Time",
ylab = "Survival",
line_size = 1.5,
ci_alpha = 0.2,
show_knots = FALSE
)
Arguments
x |
A fitted model object as returned by |
newdata |
Data frame of covariate values to compute the output for. If there are covariates in the model and this is not supplied, the following default is used: (a) if the only covariate is one factor variable, then the output is computed for each level of this factor. (b) if there are multiple covariates, or any numeric covariates, then the output is computed at the mean of each numeric covariate in the original data, and at the baseline level of each factor covariate. Note: caution is required about how treatment groups (for example)
are stored in your data. If these are coded as numeric (0/1),
then if |
t |
Vector of times at which to compute the estimates. |
tmax |
Maximum time at which to compute the estimates. If
|
km |
If The Kaplan-Meier estimates are returned in the |
niter |
Number of MCMC iterations to use to compute credible intervals. Set to a low value to make this function quicker, at the cost of some approximation error (which may not be important for plotting or model development). |
newdata0 |
Data frame of covariate values defining the "untreated" group
for use in treatment waning models. See |
wane_period |
Vector of two numbers, defining the time period over which
the hazard is interpolated between the hazard of the "treated" group (taken from |
wane_nt |
Number of intervals defining the piecewise constant approximation to the hazard during the waning period. |
ci |
If |
xlab |
X-axis label |
ylab |
Y-axis label |
line_size |
Passed to |
ci_alpha |
Transparency for the credible interval ribbons |
show_knots |
Show the locations of the spline knots as vertical lines |
Details
If the model has a single factor covariate (excluding background
hazard strata), then curves are produced for each level of this
factor if newdata
requests this (or is left to its default).
Otherwise, only a single curve is produced, illustrating the
corresponding output from hazard
.
Value
A ggplot2
plot object.