Learn R Programming

npsurv (version 0.3-3)

plot.npsurv: Plot Functions for Nonparametric Survival Estimation

Description

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.

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=NA,  
            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 npsurv (i.e., an output of function npsurv) or an object of class idf.
fn
either "surv" or "grad", to indicate plotting either the survival or the gradient function.
f
an object of class idf.
style
for how to plot the survival function on a "maximal intersection interval":

= box, plot a rectangle, which shows the uncertainty of probability allocation within the interval;

= uniform, treat it as a uniform di

xlab, ylab
x- or y-axis label.
add
= TRUE, adds the curve to the existing plot;

= FALSE, plots the curve in a new one.

col
color for all line segments, including box/rectangle borders.
fill
color for filling a box/rectangle.
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 icendata.
w
additional weights/multiplicities of the observations stored in x.
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.
...
arguments for other graphical parameters (see par).

Details

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.

References

Wang, Y. (2008). Dimension-reduced nonparametric maximum likelihood computation for interval-censored data. Computational Statistics & Data Analysis, 52, 2388-2402.

See Also

icendata, idf, npsurv.

Examples

Run this code
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

Run the code above in your browser using DataLab