plot.npsurv {npsurv} | R Documentation |
Plot Functions for Nonparametric Survival Estimation
Description
Functions for plotting nonparametric survival functions and related ones.
Usage
## S3 method for class 'npsurv'
plot(x, ...)
## S3 method for class 'idf'
plot(x, data, fn=c("surv","grad"), ...)
plotsurvidf(f, style=c("box","uniform","left","right","midpoint"),
xlab="Time", ylab="Survival Probability", col="blue3", fill=0,
add=FALSE, lty=1, lty.inf=2, xlim, ...)
plotgradidf(f, data, w=1, col1="red3", col2="blue3",
xlab="Survival Time", ylab="Gradient", xlim, ...)
Arguments
x |
an object of class |
... |
arguments for other graphical parameters (see |
fn |
either "surv" or "grad", to indicate plotting either the survival or the gradient function. |
f |
an object of class |
style |
for how to plot the survival function on a "maximal intersection interval": = = = = = |
xlab , ylab |
x- or y-axis label. |
add |
= = |
col |
color for all line segments, including box/rectangle borders. |
fill |
color for filling a box/rectangle. By default, a lighter semi-transparent color is used. |
lty |
line type |
lty.inf |
line type for the rectangle that may extend to infinity. |
data |
vector or matrix that stores observations, or an object of class
|
w |
additional weights/multiplicities of the observations stored in
|
col1 |
color for drawing maximal intersection intervals allocated with positive probabilities. |
col2 |
color for drawing all gradients and the maximal intersection intervals allocated with zero probabilities. |
xlim |
x-coordinate limit points. |
Details
plot.npsurv
and plot.idf
are wrapper functions that call
either plotsurvidf
or plotgradidf
.
plotsurvidf
plots the survival function of the nonparametric maximum
likelihood estimate (NPMLE).
plotgradidf
plots the gradient function of the NPMLE.
plotsurvidf
by default chooses a less saturated color for fill
than col
.
plotgradidf
plots gradient values as vertical lines located as the
left endpoints of the maximal intersection intervals. Each maximal
intersection interval is plotted as a wider line on the horizontal
zero-gradient line, with a circle to represent the open left endpoint of the
interval and a solid point the closed right endpoint of the interval. The
maximal intersection intervals allocated with positive probabilities have
zero gradients, and hence no vertical lines are drawn for them.
Author(s)
Yong Wang <yongwang@auckland.ac.nz>
References
Wang, Y. (2008). Dimension-reduced nonparametric maximum likelihood computation for interval-censored data. Computational Statistics & Data Analysis, 52, 2388-2402.
See Also
Examples
data(ap)
plot(r<-npsurv(ap)) # survival function
plot(r$f, ap, fn="g") # all gradients virtually zeros.
data(cancer)
cancerRT = with(cancer, cancer[group=="RT",1:2])
plot(rt<-npsurv(cancerRT), xlim=c(0,60)) # survival of RT
cancerRCT = with(cancer, cancer[group=="RCT",1:2])
plot(rct<-npsurv(cancerRCT), add=TRUE, col="green3") # survival of RCT
## as uniform dististrbutions.
plot(rt, add=TRUE, style="uniform", col="blue3")
plot(rct, add=TRUE, style="uniform", col="green3")
## plot gradients; must supply data
plot(rt, cancerRT, fn="g") # for group RT
plotgradidf(rct$f, cancerRCT) # or, for group RCT