plot.kmciLR {bpcp} | R Documentation |
Plot and lines methods for kmci
, kmciLR
, kmciLRtidy
, and kmciLRgroup
objects.
Description
Plots survival curves and/or confidence intervals. kmciLR
objects from the bpcp function will plot using base R plot.
If a kmciLRtidy
object is created using bpcpfit (plotstyle = "ggplot"), the plot will display using ggplot.
If a kmciLRgroup
object is created using bpcpfit (plotstyle = "standard"), the plot will display using base R.
Usage
## S3 method for class 'kmci'
plot(x, ...)
## S3 method for class 'kmciLR'
plot(x, XLAB = "time", YLAB = "Survival", YLIM = c(0, 1),
ciLTY = 2, ciCOL = gray(0.8), mark.time = NULL,
linetype = "both", ...)
## S3 method for class 'kmciLR'
lines(x, lty = c(2, 1), col = c(gray(0.8), gray(0)),
linetype = "both", mark.time = NULL, ...)
## S3 method for class 'kmci'
lines(x, ...)
## S3 method for class 'kmciLRtidy'
plot(x, ...)
## S3 method for class 'kmciLRgroup'
plot(x,XLAB="Time",YLAB="Survival",
YLIM=c(0,1),ciLTY=2,ciCOL=gray(.8), linetype="both", ...)
Arguments
x |
|
XLAB |
label for x axis |
YLAB |
label for y axis |
YLIM |
limits for y axis |
ciLTY |
lty (line type) for confidence intervals |
ciCOL |
col (color) for confidence intervals |
col |
vector of colors, first element used for ci second for survival curve |
lty |
vector of line types, first element used for ci second for survival curve |
mark.time |
put hash marks for censored objects (default puts marks of stype="km" but not if stype="mue") |
linetype |
character, which lines to draw: either 'both', 'surv' or 'ci' |
... |
Extra parameters to be passed. Any argument in |
Examples
data(leuk)
## kmciTG creates kmci object
fitTG<-kmciTG(leuk$time,leuk$status)
plot(fitTG)
## bpcp creates kmciLR object
fitBP<-bpcp(leuk$time,leuk$status)
lines(fitBP,lwd=3,lty=1,col=gray(.5),linetype="ci")
legend(0,.2,legend=c("Kaplan-Meier","Thomas-Grunkemeier 95 pct C
I","Beta Product 95 pct CI"),
lwd=c(1,1,3),lty=c(1,2,1),col=c(gray(0),gray(.8),gray(.5)))
data(leuk2)
## bpcpfit creates kmciLR object which is plotted with ggplot
fitBPsurv <- bpcpfit(Surv(time, status)~treatment, data=leuk2)
plot(fitBPsurv)
## this works even if no treatment variable is specified
plot(bpcpfit(Surv(time, status)~1, data=leuk2))
## if plotstyle "standard" is specified, a base R plot is produced
a <- bpcpfit(leuk2$time, leuk2$status, leuk2$treatment, plotstyle = "standard")
plot(a)
#can also create a tidy object to customize ggplot further
tidy <- tidykmciLR(fitBPsurv)
ggplot(tidy, aes(x = time, y = surv, ymin = lower, ymax = upper, col = group)) +
geom_line(show.legend=FALSE) + geom_ribbon(alpha = .2, aes(fill=group)) +
xlab("Time") + ylab("Survival") +
ggtitle("K-M curves with bpcp CIs")