Usage
survplot(fit, ...)
survplotp(fit, ...)
"survplot"(fit, ..., xlim, ylim=if(loglog) c(-5, 1.5) else if (what == "survival" & missing(fun)) c(0, 1), xlab, ylab, time.inc, what=c("survival","hazard"), type=c("tsiatis","kaplan-meier"), conf.type=c("log","log-log","plain","none"), conf.int=FALSE, conf=c("bands","bars"), mylim=NULL, add=FALSE, label.curves=TRUE, abbrev.label=FALSE, levels.only=FALSE, lty, lwd=par("lwd"), col=1, col.fill=gray(seq(.95, .75, length=5)), adj.subtitle=TRUE, loglog=FALSE, fun, n.risk=FALSE, logt=FALSE, dots=FALSE, dotsize=.003, grid=NULL, srt.n.risk=0, sep.n.risk=0.056, adj.n.risk=1, y.n.risk, cex.n.risk=.6, cex.xlab=par('cex.lab'), cex.ylab=cex.xlab, pr=FALSE)
"survplot"(fit, xlim, ylim, xlab, ylab, time.inc, state=NULL, conf=c("bands","bars","diffbands","none"), mylim=NULL, add=FALSE, label.curves=TRUE, abbrev.label=FALSE, levels.only=FALSE, lty,lwd=par('lwd'), col=1, col.fill=gray(seq(.95, .75, length=5)), loglog=FALSE, fun, n.risk=FALSE, aehaz=FALSE, times=NULL, logt=FALSE, dots=FALSE, dotsize=.003, grid=NULL, srt.n.risk=0, sep.n.risk=.056, adj.n.risk=1, y.n.risk, cex.n.risk=.6, cex.xlab=par('cex.lab'), cex.ylab=cex.xlab, pr=FALSE, ...)
"survplotp"(fit, xlim, ylim, xlab, ylab, time.inc, state=NULL, conf=c("bands", "none"), mylim=NULL, abbrev.label=FALSE, col=colorspace::rainbow_hcl, levels.only=TRUE, loglog=FALSE, fun=function(y) y, aehaz=FALSE, times=NULL, logt=FALSE, pr=FALSE, ...)
survdiffplot(fit, order=1:2, fun=function(y) y, xlim, ylim, xlab, ylab="Difference in Survival Probability", time.inc, conf.int, conf=c("shaded", "bands","diffbands","none"), add=FALSE, lty=1, lwd=par('lwd'), col=1, n.risk=FALSE, grid=NULL, srt.n.risk=0, adj.n.risk=1, y.n.risk, cex.n.risk=.6, cex.xlab=par('cex.lab'), cex.ylab=cex.xlab, convert=function(f) f)
Arguments
fit
result of fit (cph
, psm
, npsurv
,
survest.psm
). For survdiffplot
, fit
must be the
result of npsurv
.
...
list of factors with names used in model. For fits from npsurv
these arguments do not appear - all strata are plotted. Otherwise the
first factor listed is the factor used to determine different survival
curves. Any other factors are used to specify single constants to be
adjusted to, when defaults given to fitting routine (through
limits
) are not used. The value given to factors is the original
coding of data given to fit, except that for categorical or strata
factors the text string levels may be specified. The form of values
given to the first factor are none (omit the equal sign to use default range
or list of all values if variable is discrete), "text"
if factor
is categorical, c(value1, value2, ...)
, or a function which
returns a vector, such as seq(low,high,by=increment)
. Only the
first factor may have the values omitted. In this case the Low
effect
, Adjust to
, and High effect
values will be used
from datadist
if the variable is continuous. For variables not
defined to datadist
, you must specify non-missing constant
settings (or a vector of settings for the one displayed variable). Note
that since npsurv
objects do not use the variable list in
...
, you can specify any extra arguments to labcurve
by
adding them at the end of the list of arguments. For survplotp
... (e.g., height
, width
) is passed to plotly::plot_ly
.
xlim
a vector of two numbers specifiying the x-axis range for follow-up time.
Default is (0,maxtime)
where maxtime
was the pretty()
d version
of the maximum follow-up time
in any stratum, stored in fit$maxtime
. If logt=TRUE
,
default is (1, log(maxtime))
.
ylim
y-axis limits. Default is c(0,1)
for survival, and
c(-5,1.5)
if loglog=TRUE
. If fun
or
loglog=TRUE
are given and ylim
is not, the limits will be
computed from the data. For what="hazard"
, default
limits are computed from the first hazard function plotted.
xlab
x-axis label. Default is units
attribute of failure time
variable given to Surv
.
ylab
y-axis label. Default is "Survival Probability"
or
"log(-log Survival Probability)"
. If fun
is given, the default
is ""
. For what="hazard"
, the default is
"Hazard Function"
. For a multi-state/competing risk application
the default is "Cumulative Incidence"
.
time.inc
time increment for labeling the x-axis and printing numbers at risk.
If not specified, the value
of time.inc
stored with the model fit will be used.
state
the state/event cause to use in plotting if the fit was for
a multi-state/competing risk Surv
object
type
specifies type of estimates, "tsiatis"
(the default) or "kaplan-meier"
.
"tsiatis"
here corresponds to the Breslow
estimator. This is ignored if survival estimates stored with surv=TRUE
are
being used. For fits from npsurv
, this argument
is also ignored, since it is specified as an argument to npsurv
.
conf.type
specifies the basis for confidence limits. This argument is
ignored for fits from npsurv
.
conf.int
Default is FALSE
. Specify e.g. .95
to plot 0.95 confidence bands.
For fits from parametric survival models, or Cox models with
x=TRUE
and y=TRUE
specified to the fit, the exact
asymptotic formulas will be used to compute standard errors, and
confidence limits are based on log(-log S(t))
if loglog=TRUE
.
If x=TRUE
and y=TRUE
were not specified to cph
but
surv=TRUE
was, the standard errors stored for the underlying
survival curve(s) will be used. These agree with the former if
predictions are requested at the mean value of X beta or if there are
only stratification factors in the model. This argument is ignored for
fits from npsurv
, which must have previously specified
confidence interval specifications. For survdiffplot
if
conf.int
is not specified, the level used in the call to
npsurv
will be used.
conf
"bars"
for confidence bars at each time.inc
time point. If the fit
was from cph(..., surv=TRUE)
, the time.inc
used will be
that stored with the fit. Use conf="bands"
(the default) for
bands using standard errors at each failure time. For npsurv
objects only, conf
may also be "none"
, indicating that
confidence interval information stored with the npsurv
result
should be ignored. For npsurv
and survdiffplot
,
conf
may be "diffbands"
whereby a shaded region is drawn
for comparing two curves. The polygon is centered at the midpoint of
the two survival estimates and the height of the polygon is 1/2 the
width of the approximate conf.int
pointwise confidence region.
Survival curves not overlapping the shaded area are approximately
significantly different at the 1 - conf.int
level.
mylim
used to curtail computed ylim
. When ylim
is
not given by the user, the computed limits are expanded to force
inclusion of the values specified in mylim
.
what
defaults to "survival"
to plot survival estimates. Set to
"hazard"
or an abbreviation to plot the hazard function (for
psm
fits only). Confidence intervals are not available for
what="hazard"
.
add
set to TRUE
to add curves to an existing plot.
label.curves
default is TRUE
to use labcurve
to label curves where they are farthest
apart. Set label.curves
to a list
to specify options to
labcurve
, e.g., label.curves=list(method="arrow", cex=.8)
.
These option names may be abbreviated in the usual way arguments
are abbreviated. Use for example label.curves=list(keys=1:5)
to draw symbols (as in pch=1:5
- see points
)
on the curves and automatically position a legend
in the most empty part of the plot. Set label.curves=FALSE
to
suppress drawing curve labels. The col
, lty
, lwd
, and type
parameters are automatically passed to labcurve
, although you
can override them here. To distinguish curves by line types and
still have labcurve
construct a legend, use for example
label.curves=list(keys="lines")
. The negative value for the
plotting symbol will suppress a plotting symbol from being drawn
either on the curves or in the legend.
abbrev.label
set to TRUE
to abbreviate()
curve labels that are plotted
levels.only
set to TRUE
to remove variablename=
from the start of
curve labels.
lty
vector of line types to use for different factor levels. Default is
c(1,3,4,5,6,7,...)
.
lwd
vector of line widths to use for different factor levels. Default is
current par
setting for lwd
.
col
color for curve, default is 1
. Specify a vector to assign different
colors to different curves. For survplotp
, col
is a
vector of colors corresponding to strata, or a function that will be
called to generate such colors.
col.fill
a vector of colors to used in filling confidence bands
adj.subtitle
set to FALSE
to suppress plotting subtitle with levels of adjustment factors
not plotted. Defaults to TRUE
.
This argument is ignored for npsurv
.
loglog
set to TRUE
to plot log(-log Survival)
instead of Survival
fun
specifies any function to translate estimates and confidence limits
before plotting. If the fit is a multi-state object the default for
fun
is function(y) 1 - y
to draw cumulative incidence curves.
logt
set to TRUE
to plot log(t)
instead of t
on the x-axis
n.risk
set to TRUE
to add number of subjects at risk for each curve, using the
surv.summary
created by cph
or using the failure times used in
fitting the model if y=TRUE
was specified to the fit or if the fit
was from npsurv
.
The numbers are placed at the bottom
of the graph unless y.n.risk
is given.
If the fit is from survest.psm
, n.risk
does not apply.
srt.n.risk
angle of rotation for leftmost number of subjects at risk (since this number
may run into the second or into the y-axis). Default is 0
.
adj.n.risk
justification for leftmost number at risk. Default is 1
for right
justification.
Use 0
for left justification, .5
for centered.
sep.n.risk
multiple of upper y limit - lower y limit for separating lines of text
containing number of subjects at risk. Default is .056*(ylim[2]-ylim[1])
.
y.n.risk
When n.risk=TRUE
, the default is to place numbers of patients at
risk above the x-axis. You can specify a y-coordinate for the bottom
line of the numbers using y.n.risk
. Specify
y.n.risk='auto'
to place the numbers below the x-axis at a
distance of 1/3 of the range of ylim
.
cex.n.risk
character size for number of subjects at risk (when n.risk
is
TRUE
)
cex.xlab
cex
for x-axis label
cex.ylab
cex
for y-axis label
dots
set to TRUE
to plot a grid of dots. Will be plotted at every
time.inc
(see cph
) and at survival increments of .1 (if
d>.4
), .05 (if .2 < d <= .4<="" code="">), or .025 (if d <= .2<="" code="">),
where d
is the range of survival displayed.
=>
=>
dotsize
size of dots in inches
grid
defaults to NULL
(not drawing grid lines). Set to TRUE
to
plot gray(.8)
grid lines, or specify any color.
pr
set to TRUE
to print survival curve coordinates used in the plots
aehaz
set to TRUE
to add number of events and exponential
distribution hazard rate estimates in curve labels. For
competing risk data the number of events is for the cause of interest,
and the hazard rate is the number of events divided by the sum of all
failure and censoring times.
times
a numeric vector of times at which to compute cumulative
incidence probability estimates to add to curve labels
order
an integer vector of length two specifying the order of groups when
computing survival differences. The default of 1:2
indicates
that the second group is subtracted from the first. Specify
order=2:1
to instead subtract the first from the second. A
subtitle indicates what was done.
convert
a function to convert the output of
summary.survfitms
to pick off the data needed for a single state