cfit: Compute an ECDF and Distribution Parameters for Censored Data

View source: R/cfit.R

cfitR Documentation

Compute an ECDF and Distribution Parameters for Censored Data

Description

Computes the empirical cumulative distribution function (ECDF) for censored data. Estimates parameters of the distribution, including the mean and quantiles.

Usage

cfit(
  y,
  cens,
  conf = 0.95,
  qtls = c(0.1, 0.25, 0.5, 0.75, 0.9),
  plot.pos = 0.375,
  q.type = 7,
  Cdf = TRUE,
  ecdf.col = 1,
  km.orig = FALSE,
  printstat = TRUE,
  Ylab = NULL
)

Arguments

y

Concentrations plus detection limits for indicator formatted data.

cens

Censoring indicators (logical. 1 or TRUE = censored, 0 or FALSE = detected) for indicator formatted data.

conf

The confidence coefficient for confidence intervals around the Kaplan-Meier mean and median. Default = 0.95.

qtls

Probabilities for the quantiles to be estimated. Defaults are (0.10, 0.25, 0.50, 0.75, 0.90). You may add and/or substitute probabilities – all must be between and not including 0 to 1.

plot.pos

numeric scalar between 0 and 1 containing the value of the plotting position constant. The default value is plot.pos=0.375, the Blom plotting position

q.type

an integer between 1 and 9 selecting one of the nine quantile algorithms detailed below to be used. See stats::quantile for more detail, default is set to 7.

Cdf

Logical TRUE/FALSE indicator of whether to plot the empirical cumulative distribution function (cdf).

ecdf.col

Color for the ecdf plotted step function line. Default is black.

km.orig

If TRUE, Kaplan-Meier results in the realm below detection limits reported as "NA". If FALSE (default), information in the detection limits is used and results in the realm of detections limits reported as "< DL", where DL is the appropriate detection limit.

printstat

Logical TRUE/FALSE option of whether to print the resulting statistics in the console window, or not. Default is TRUE.

Ylab

Optional input text in quotes to be used as the variable name on the ecdf plot. The default is the name of the y1 input variable.

Details

Moment statistics are estimated using the enparCensored function of the EnvStats package. This avoids a small bias in the mean produced by the NADA package's cenfit function, which uses the reverse Kaplan-Meier procedure, converting left-censored to right-censored data prior to computing the ecdf and mean. See Gillespie et al. for more discussion on the bias of the estimate of the mean.

Quantiles and confidence limits on the median are estimated using the quantile function of the survfit command. See ?quantiles for choosing the q.type; default q.type = 7.

All printed values will also be output to an object if saved. Values are character because of the possibility of a ⁠<1⁠, but if no < symbol can be converted to numeric using the as.numeric(...) command. For data without censoring cfit will also return values. For data without censoring cfit will also return values. In that case it returns standard arithmetic mean, standard deviation and quantiles instead of K-M versions.

Value

If printstat=TRUE: Based on the provided conf value, Kaplan-Meier summary statistics (mean,sd,median), lower and upper confidence intervals around the mean and median value, sample size and percent of censored samples are returned. The specified quantile values are also printed and returned.

If Cdf=TRUE: The ecdf of censored data is plotted.

References

Helsel, D.R., 2011. Statistics for Censored Environmental Data using Minitab and R, 2nd ed. John Wiley & Sons, USA, N.J.

Gillespie, B.W., et al., 2010. Estimating Population Distributions When Some Data Are Below a Limit of Detection by Using a Reverse Kaplan-Meier Estimator. Epidemiology 21, 564-570.

Millard, S.P, 2013. EnvStats: An R Package for Environmental Statistics, 2nd ed. Springer Science+Business Media, USA, N.Y. DOI 10.1007/978-1-4614-8456-1© Springer Science+Business Media New York 2013”

Excerpt From: Steven P. Millard. “EnvStats.” Apple Books.

See Also

survival::survfit

Examples


data(Brumbaugh)

cfit(Brumbaugh$Hg,Brumbaugh$HgCen)


NADA2 documentation built on Oct. 20, 2023, 5:07 p.m.