Returns a list of “ordered” observations and associated plotting positions based on Type I left-censored or right-censored data. These plotting positions may be used to construct empirical cumulative distribution plots or quantile-quantile plots, or to estimate distribution parameters.
Usage
ppointsCensored(x, censored, censoring.side = "left",
prob.method = "michael-schucany", plot.pos.con = 0.375)Details
Extended methods and derivations are available in
Distribution diagnostics, transformations, and probability plots: ppointsCensored.
Open the vignette locally with
vignette("distribution-diagnostics", package = "EnvStats").
Arguments
- x
numeric vector of observations. Missing (
NA), undefined (NaN), and infinite (Inf,-Inf) values are allowed but will be removed.- censored
numeric or logical vector indicating which values of
xare censored. This must be the same length asx. If the mode ofcensoredis"logical",TRUEvalues correspond to elements ofxthat are censored, andFALSEvalues correspond to elements ofxthat are not censored. If the mode ofcensoredis"numeric", it must contain only1's and0's;1corresponds toTRUEand0corresponds toFALSE. Missing (NA) values are allowed but will be removed.- censoring.side
character string indicating on which side the censoring occurs. The possible values are
"left"(the default) and"right".- prob.method
character string indicating what method to use to compute the plotting positions (empirical probabilities). Possible values are:
"kaplan-meier"(product-limit method of Kaplan and Meier (1958)),"modified kaplan-meier"(modification of Kaplan-Meier method),"nelson"(hazard plotting method of Nelson (1972)),"michael-schucany"(generalization of the product-limit method due to Michael and Schucany (1986)), and"hirsch-stedinger"(generalization of the product-limit method due to Hirsch and Stedinger (1987)).The default value is
prob.method="michael-schucany".The
"nelson"method is only available forcensoring.side="right", and the"modified kaplan-meier"method is only available forcensoring.side="left". See the DETAILS section for more explanation.- plot.pos.con
numeric scalar between 0 and 1 containing the value of the plotting position constant. The default value is
plot.pos.con=0.375. See the DETAILS section for more information. This argument is used only ifprob.methodis equal to"michael-schucany"or"hirsch-stedinger".
Value
ppointsCensored returns a list with the following components:
- Order.Statistics
numeric vector of the “ordered” observations.
- Cumulative.Probabilities
numeric vector of the associated plotting positions.
- Censored
logical vector indicating which of the ordered observations are censored.
- Censoring.Side
character string indicating whether the data are left- or right-censored. This is same value as the argument
censoring.side.- Prob.Method
character string indicating what method was used to compute the plotting positions. This is the same value as the argument
prob.method.
Optional Component (only present when prob.method="michael-schucany" or prob.method="hirsch-stedinger"):
- Plot.Pos.Con
numeric scalar containing the value of the plotting position constant that was used. This is the same as the argument
plot.pos.con.
References
Chambers, J.M., W.S. Cleveland, B. Kleiner, and P.A. Tukey. (1983). Graphical Methods for Data Analysis. Duxbury Press, Boston, MA, pp.11-16.
Cleveland, W.S. (1993). Visualizing Data. Hobart Press, Summit, New Jersey, 360pp.
D'Agostino, R.B. (1986a). Graphical Analysis. In: D'Agostino, R.B., and M.A. Stephens, eds. Goodness-of Fit Techniques. Marcel Dekker, New York, Chapter 2, pp.7-62.
Gillespie, B.W., Q. Chen, H. Reichert, A. Franzblau, E. Hedgeman, J. Lepkowski, P. Adriaens, A. Demond, W. Luksemburg, and D.H. Garabrant. (2010). Estimating Population Distributions When Some Data Are Below a Limit of Detection by Using a Reverse Kaplan-Meier Estimator. Epidemiology 21(4), S64–S70.
Helsel, D.R. (2012). Statistics for Censored Environmental Data Using Minitab and R, Second Edition. John Wiley & Sons, Hoboken, New Jersey.
Helsel, D.R., and T.A. Cohn. (1988). Estimation of Descriptive Statistics for Multiply Censored Water Quality Data. Water Resources Research 24(12), 1997-2004.
Hirsch, R.M., and J.R. Stedinger. (1987). Plotting Positions for Historical Floods and Their Precision. Water Resources Research 23(4), 715-727.
Kaplan, E.L., and P. Meier. (1958). Nonparametric Estimation From Incomplete Observations. Journal of the American Statistical Association 53, 457-481.
Lee, E.T., and J. Wang. (2003). Statistical Methods for Survival Data Analysis, Third Edition. John Wiley and Sons, New York.
Michael, J.R., and W.R. Schucany. (1986). Analysis of Data from Censored Samples. In D'Agostino, R.B., and M.A. Stephens, eds. Goodness-of Fit Techniques. Marcel Dekker, New York, 560pp, Chapter 11, 461-496.
Nelson, W. (1972). Theory and Applications of Hazard Plotting for Censored Failure Data. Technometrics 14, 945-966.
USEPA. (2009). Statistical Analysis of Groundwater Monitoring Data at RCRA Facilities, Unified Guidance. EPA 530/R-09-007, March 2009. Office of Resource Conservation and Recovery Program Implementation and Information Division. U.S. Environmental Protection Agency, Washington, D.C. Chapter 15.
USEPA. (2010). Errata Sheet - March 2009 Unified Guidance. EPA 530/R-09-007a, August 9, 2010. Office of Resource Conservation and Recovery, Program Information and Implementation Division. U.S. Environmental Protection Agency, Washington, D.C.
Author
Steven P. Millard (EnvStats@ProbStatInfo.com)
Note
For censored data sets, plotting positions may be used to construct empirical cumulative distribution
plots (see ecdfPlotCensored), construct quantile-quantile plots
(see qqPlotCensored), or to estimate distribution parameters
(see FcnsByCatCensoredData).
The function survfit in the built-in R library
survival computes the survival function for right-censored, left-censored, or
interval-censored data. Calling survfit with
type="kaplan-meier" will produce similar results to calling
ppointsCensored with prob.method="kaplan-meier". Also, calling
survfit with type="fh2" will produce similar results
to calling ppointsCensored with prob.method="nelson".
Helsel and Cohn (1988, p.2001) found very little effect of changing the value of the plotting position constant when using the method of Hirsch and Stedinger (1987) to compute plotting positions for multiply left-censored data. In general, there will be very little difference between plotting positions computed by the different methods except in the case of very small samples and a large amount of censoring.
Examples
# Generate 20 observations from a normal distribution with mean=20 and sd=5,
# censor all observations less than 18, then compute plotting positions for
# this data set. Compare the plotting positions to the plotting positions
# for the uncensored data set. Note that the plotting positions for the
# censored data set start at the first ordered uncensored observation and
# that for values of x > 18 the plotting positions for the two data sets 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
censored
#> [1] FALSE FALSE TRUE FALSE TRUE FALSE FALSE FALSE FALSE TRUE TRUE TRUE
#> [13] FALSE TRUE TRUE FALSE FALSE FALSE FALSE FALSE
# [1] FALSE FALSE TRUE FALSE TRUE FALSE FALSE FALSE FALSE TRUE TRUE TRUE
#[13] FALSE TRUE TRUE FALSE FALSE FALSE FALSE FALSE
sum(censored)
#> [1] 7
#[1] 7
new.x <- x
new.x[censored] <- 18
round(sort(new.x),1)
#> [1] 18.0 18.0 18.0 18.0 18.0 18.0 18.0 18.1 18.7 19.6 20.2 20.3 20.6 21.4 21.8
#> [16] 21.8 23.2 26.2 26.8 29.7
# [1] 18.0 18.0 18.0 18.0 18.0 18.0 18.0 18.1 18.7 19.6 20.2 20.3 20.6 21.4
#[15] 21.8 21.8 23.2 26.2 26.8 29.7
p.list <- ppointsCensored(new.x, censored)
p.list
#> $Order.Statistics
#> [1] 18.00000 18.00000 18.00000 18.00000 18.00000 18.00000 18.00000 18.09771
#> [9] 18.65418 19.58594 20.21931 20.26851 20.55296 21.38869 21.76359 21.82364
#> [17] 23.16804 26.16527 26.84336 29.67340
#>
#> $Cumulative.Probabilities
#> [1] 0.3765432 0.3765432 0.3765432 0.3765432 0.3765432 0.3765432 0.3765432
#> [8] 0.3765432 0.4259259 0.4753086 0.5246914 0.5740741 0.6234568 0.6728395
#> [15] 0.7222222 0.7716049 0.8209877 0.8703704 0.9197531 0.9691358
#>
#> $Censored
#> [1] TRUE TRUE TRUE TRUE TRUE TRUE TRUE FALSE FALSE FALSE FALSE FALSE
#> [13] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
#>
#> $Censoring.Side
#> [1] "left"
#>
#> $Prob.Method
#> [1] "michael-schucany"
#>
#> $Plot.Pos.Con
#> [1] 0.375
#>
#$Order.Statistics
# [1] 18.00000 18.00000 18.00000 18.00000 18.00000 18.00000 18.00000 18.09771
# [9] 18.65418 19.58594 20.21931 20.26851 20.55296 21.38869 21.76359 21.82364
#[17] 23.16804 26.16527 26.84336 29.67340
#
#$Cumulative.Probabilities
# [1] 0.3765432 0.3765432 0.3765432 0.3765432 0.3765432 0.3765432 0.3765432
# [8] 0.3765432 0.4259259 0.4753086 0.5246914 0.5740741 0.6234568 0.6728395
#[15] 0.7222222 0.7716049 0.8209877 0.8703704 0.9197531 0.9691358
#
#$Censored
# [1] TRUE TRUE TRUE TRUE TRUE TRUE TRUE FALSE FALSE FALSE FALSE FALSE
#[13] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
#
#$Censoring.Side
#[1] "left"
#
#$Prob.Method
#[1] "michael-schucany"
#
#$Plot.Pos.Con
#[1] 0.375
#----------
# Round off plotting positions to two decimal places
# and compare to plotting positions that ignore censoring
#--------------------------------------------------------
round(p.list$Cum, 2)
#> [1] 0.38 0.38 0.38 0.38 0.38 0.38 0.38 0.38 0.43 0.48 0.52 0.57 0.62 0.67 0.72
#> [16] 0.77 0.82 0.87 0.92 0.97
# [1] 0.38 0.38 0.38 0.38 0.38 0.38 0.38 0.38 0.43 0.48 0.52 0.57 0.62 0.67
#[15] 0.72 0.77 0.82 0.87 0.92 0.97
round(ppoints(x, a=0.375), 2)
#> [1] 0.03 0.08 0.13 0.18 0.23 0.28 0.33 0.38 0.43 0.48 0.52 0.57 0.62 0.67 0.72
#> [16] 0.77 0.82 0.87 0.92 0.97
# [1] 0.03 0.08 0.13 0.18 0.23 0.28 0.33 0.38 0.43 0.48 0.52 0.57 0.62 0.67
#[15] 0.72 0.77 0.82 0.87 0.92 0.97
#----------
# Clean up
#---------
rm(x, censored, new.x, p.list)
#----------------------------------------------------------------------------
# Reproduce the example in Appendix B of Helsel and Cohn (1988). The data
# are stored in Helsel.Cohn.88.appb.df. This data frame contains 18
# observations, of which 9 are censored below one of 2 distinct censoring
# levels.
Helsel.Cohn.88.app.b.df
#> Conc.orig Conc Censored
#> 1 <1 1 TRUE
#> 2 <1 1 TRUE
#> 3 <1 1 TRUE
#> 4 <1 1 TRUE
#> 5 <1 1 TRUE
#> 6 <1 1 TRUE
#> 7 3 3 FALSE
#> 8 7 7 FALSE
#> 9 9 9 FALSE
#> 10 <10 10 TRUE
#> 11 <10 10 TRUE
#> 12 <10 10 TRUE
#> 13 12 12 FALSE
#> 14 15 15 FALSE
#> 15 20 20 FALSE
#> 16 27 27 FALSE
#> 17 33 33 FALSE
#> 18 50 50 FALSE
# Conc.orig Conc Censored
#1 <1 1 TRUE
#2 <1 1 TRUE
#...
#17 33 33 FALSE
#18 50 50 FALSE
p.list <- with(Helsel.Cohn.88.app.b.df,
ppointsCensored(Conc, Censored, prob.method="hirsch-stedinger", plot.pos.con=0))
lapply(p.list[1:2], round, 3)
#> $Order.Statistics
#> [1] 1 1 1 1 1 1 3 7 9 10 10 10 12 15 20 27 33 50
#>
#> $Cumulative.Probabilities
#> [1] 0.063 0.127 0.190 0.254 0.317 0.381 0.500 0.556 0.611 0.167 0.333 0.500
#> [13] 0.714 0.762 0.810 0.857 0.905 0.952
#>
#$Order.Statistics
# [1] 1 1 1 1 1 1 3 7 9 10 10 10 12 15 20 27 33 50
#
#$Cumulative.Probabilities
# [1] 0.063 0.127 0.190 0.254 0.317 0.381 0.500 0.556 0.611 0.167 0.333 0.500
#[13] 0.714 0.762 0.810 0.857 0.905 0.952
# Clean up
#---------
rm(p.list)
#----------------------------------------------------------------------------
# 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.
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
#> 6 1 Well.2 <5 5.0 TRUE
#> 7 2 Well.2 7.7 7.7 FALSE
#> 8 3 Well.2 53.6 53.6 FALSE
#> 9 4 Well.2 9.5 9.5 FALSE
#> 10 5 Well.2 45.9 45.9 FALSE
#> 11 1 Well.3 <5 5.0 TRUE
#> 12 2 Well.3 5.3 5.3 FALSE
#> 13 3 Well.3 12.6 12.6 FALSE
#> 14 4 Well.3 106.3 106.3 FALSE
#> 15 5 Well.3 34.5 34.5 FALSE
#> 16 1 Well.4 6.3 6.3 FALSE
#> 17 2 Well.4 11.9 11.9 FALSE
#> 18 3 Well.4 10 10.0 FALSE
#> 19 4 Well.4 <2 2.0 TRUE
#> 20 5 Well.4 77.2 77.2 FALSE
#> 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
# 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
p.list.EPA <- with(EPA.09.Ex.15.1.manganese.df,
ppointsCensored(Manganese.ppb, Censored,
prob.method = "kaplan-meier"))
data.frame(Mn = p.list.EPA$Order.Statistics, Censored = p.list.EPA$Censored,
CDF = p.list.EPA$Cumulative.Probabilities)
#> Mn Censored CDF
#> 1 2.0 TRUE 0.21
#> 2 2.0 TRUE 0.21
#> 3 2.0 TRUE 0.21
#> 4 3.3 FALSE 0.28
#> 5 5.0 TRUE 0.28
#> 6 5.0 TRUE 0.28
#> 7 5.0 TRUE 0.28
#> 8 5.3 FALSE 0.32
#> 9 6.3 FALSE 0.36
#> 10 7.7 FALSE 0.40
#> 11 8.4 FALSE 0.44
#> 12 9.5 FALSE 0.48
#> 13 10.0 FALSE 0.52
#> 14 11.9 FALSE 0.56
#> 15 12.1 FALSE 0.60
#> 16 12.6 FALSE 0.64
#> 17 16.9 FALSE 0.68
#> 18 17.9 FALSE 0.72
#> 19 21.6 FALSE 0.76
#> 20 22.7 FALSE 0.80
#> 21 34.5 FALSE 0.84
#> 22 45.9 FALSE 0.88
#> 23 53.6 FALSE 0.92
#> 24 77.2 FALSE 0.96
#> 25 106.3 FALSE 1.00
# Mn Censored CDF
#1 2.0 TRUE 0.21
#2 2.0 TRUE 0.21
#3 2.0 TRUE 0.21
#4 3.3 FALSE 0.28
#5 5.0 TRUE 0.28
#6 5.0 TRUE 0.28
#7 5.0 TRUE 0.28
#8 5.3 FALSE 0.32
#9 6.3 FALSE 0.36
#10 7.7 FALSE 0.40
#11 8.4 FALSE 0.44
#12 9.5 FALSE 0.48
#13 10.0 FALSE 0.52
#14 11.9 FALSE 0.56
#15 12.1 FALSE 0.60
#16 12.6 FALSE 0.64
#17 16.9 FALSE 0.68
#18 17.9 FALSE 0.72
#19 21.6 FALSE 0.76
#20 22.7 FALSE 0.80
#21 34.5 FALSE 0.84
#22 45.9 FALSE 0.88
#23 53.6 FALSE 0.92
#24 77.2 FALSE 0.96
#25 106.3 FALSE 1.00
#----------
# Clean up
#---------
rm(p.list.EPA)