ecdfPlotCensored(x, censored, censoring.side = "left", discrete = FALSE,
prob.method = "michael-schucany", plot.pos.con = 0.375, plot.it = TRUE,
add = FALSE, ecdf.col = 1, ecdf.lwd = 3 * par("cex"), ecdf.lty = 1,
include.cen = FALSE, cen.pch = ifelse(censoring.side == "left", 6, 2),
cen.cex = par("cex"), cen.col = 4, ...,
type = ifelse(discrete, "s", "l"), main = NULL, xlab = NULL, ylab = NULL,
xlim = NULL, ylim = NULL)
NA
), undefined (NaN
), and
infinite (Inf
, -Inf
) values are allowed but will be removed.x
are censored. This must be the
same length as x
. If the mode of censored
is "logical"
, TRUE
values
correspond to elements of "left"
(the default) and "right"
.x
is discrete
(discrete=TRUE
) or continuous (discrete=FALSE
; the default)."kaplan-meier"
(product-limit method of Kaplan and Meier (1958)),
"nelson"
(hazard plotting plot.pos.con=0.375
. See the DETAILS section for more information.
This argument is used only if prob.method
isadd
)
on the current graphics device. The default value is plot.it=TRUE
.add=TRUE
)
or generate a new plot (add=FALSE
; the default). This argument is ignored if
plot.it=FALSE
.ecdf.col=1
. See the entry for col
in the help file for
par
ecdf.lwd=3*par("cex")
. See the entry for lwd
in the help file for par
for more informatecdf.lty=1
. See the entry for lty
in the help file for par
for more information.include.cen=FALSE
. If include.cen=TRUE
, censored values are plotted using the
plotting character indicated by the argument <cen.pch=2
(hollow triangle pointing up) when censoring.side="right"
,
and cen.pch=6
(hcex
in the help file for
cen.col=4
. See the entry for col
in
the help file for
ecdfPlotCensored
returns a list with the following components:censoring.side
.prob.method
.prob.method="michael-schucany"
or
prob.method="hirsch-stedinger"
):plot.pos.con
.ecdfPlotCensored
does exactly the same thing as
ecdfPlot
, except it calls the function ppointsCensored
to compute the plotting positions (estimated cumulative probabilities) for the
uncensored observations.
If plot.it=TRUE
, the estimated cumulative probabilities for the uncensored
observations are plotted against the uncensored observations. By default, the
function ecdfPlotCensored
plots a step function when discrete=TRUE
,
and plots a straight line between points when discrete=FALSE
. The user may
override these defaults by supplying the graphics parameter
type (type="s"
for a step function, type="l"
for linear interpolation,
type="p"
for points only, etc.).
If include.cen=TRUE
, censored observations are included on the plot as points. The arguments
cen.pch
, cen.cex
, and cen.col
control the appearance of these points.
In cases where x
is a random sample, the emprical cdf will change from sample to sample and
the variability in these estimates can be dramatic for small sample sizes. Caution must be used in
interpreting the empirical cdf when a large percentage of the observations are censored.ppoints
, ppointsCensored
, ecdfPlot
,
qqPlot
, qqPlotCensored
, cdfPlot
,
cdfCompareCensored
.# Generate 20 observations from a normal distribution with mean=20 and sd=5,
# censor all observations less than 18, then generate an empirical cdf plot
# for the complete data set and the censored data set. Note that the empirical
# cdf plot for the censored data set starts at the first ordered uncensored
# observation, and that for values of x > 18 the two emprical cdf plots are
# exactly the same. This is because there is only one censoring level and
# no uncensored observations fall below the censored observations.
# (Note: the call to set.seed simply allows you to reproduce this example.)
set.seed(333)
x <- rnorm(20, mean=20, sd=5)
censored <- x < 18
sum(censored)
#[1] 7
new.x <- x
new.x[censored] <- 18
dev.new()
ecdfPlot(x, xlim = range(pretty(x)),
main = "Empirical CDF Plot for
Complete Data Set")
dev.new()
ecdfPlotCensored(new.x, censored, xlim = range(pretty(x)),
main="Empirical CDF Plot for
Censored Data Set")
# Clean up
#---------
rm(x, censored, new.x)
#------------------------------------------------------------------------------------
# Example 15-1 of USEPA (2009, page 15-10) gives an example of
# computing plotting positions based on censored manganese
# concentrations (ppb) in groundwater collected at 5 monitoring
# wells. The data for this example are stored in
# EPA.09.Ex.15.1.manganese.df. Here we will create an empirical
# CDF plot based on the Kaplan-Meier method.
EPA.09.Ex.15.1.manganese.df
# Sample Well Manganese.Orig.ppb Manganese.ppb Censored
#1 1 Well.1 <5 5.0 TRUE
#2 2 Well.1 12.1 12.1 FALSE
#3 3 Well.1 16.9 16.9 FALSE
#4 4 Well.1 21.6 21.6 FALSE
#5 5 Well.1 <2 2.0 TRUE
#...
#21 1 Well.5 17.9 17.9 FALSE
#22 2 Well.5 22.7 22.7 FALSE
#23 3 Well.5 3.3 3.3 FALSE
#24 4 Well.5 8.4 8.4 FALSE
#25 5 Well.5 <2 2.0 TRUE
dev.new()
with(EPA.09.Ex.15.1.manganese.df,
ecdfPlotCensored(Manganese.ppb, Censored,
prob.method = "kaplan-meier", ecdf.col = "blue",
main = "Empirical CDF of Manganese Data
Based on Kaplan-Meier"))
#==========
# Clean up
#---------
graphics.off()
Run the code above in your browser using DataLab