Learn R Programming

fitdistrplus (version 0.3-4)

cdfcompcens: Compares various fitted distributions to censored data on a cdf plot

Description

Plots the empirical cumulative distribution (censored continuous data) with theoretical ones corresponding to various fitted distributions.

Usage

cdfcompcens(ft,xlogscale=FALSE,addlegend=TRUE,legendtext,datacol,
fitcol,fitlty,xlab,ylab,main,xlegend = "bottomright",
ylegend = NULL, ...)

Arguments

ft
A list of object of class 'fitdist'.
xlogscale
If TRUE the cdf plot uses a log scale for data (x axis)
addlegend
If TRUE a legend is added to the plot to link colors and types of lines to the fitted distributions
legendtext
An expression vector of length the number of fits to compare, so the length of list ft
datacol
A specification of the color to be used in plotting data points (ecdf)
fitcol
A vector of length the number of fits to compare specifying the colors of lines used to plot fitted cumulative distributions
fitlty
A vector of length the number of fits to compare specifying the types of lines used to plot fitted cumulative distributions
xlab
A title for the x axis
ylab
A title for the y axis
main
An overall title for the plot
xlegend,ylegend
the x and y co-ordinates to be used to position the legend. They can be specified by keyword or in any way which is accepted by 'xy.coords': See legend for details.
...
further graphical arguments passed to graphical functions used in cdfcompcens

Details

Empirical and theoretical distributions are simply plotted in cdf. The EM approach of Turnbull (Turnbull, 1974) is used to compute the overall empirical cdf curve with confidence intervals, by calls to functions survfit and plot.survfit from the survival package. By default a legend is added to the plot. Arguments legendtext,datacol,fitcol,fitlty,xlab,ylab,main,xlegend,ylegend are optional and fixed to default values if omitted.

References

Turnbull BW (1974) Nonparametric estimation of a survivorship function with doubly censored data.Journal of American Statistical Association, 69, 169-173.

See Also

plotdistcens, survfit.formula, legend.

Examples

Run this code
# (1) Plot various distributions fitted to bacterial contamination data
#
data(smokedfish)
fitsfn <- fitdistcens(smokedfish,"norm")
summary(fitsfn)

fitsfl <- fitdistcens(smokedfish,"logis")
summary(fitsfl)

dgumbel <- function(x,a,b) 1/b*exp((a-x)/b)*exp(-exp((a-x)/b))
pgumbel <- function(q,a,b) exp(-exp((a-q)/b))
qgumbel <- function(p,a,b) a-b*log(-log(p))
fitsfg<-fitdistcens(smokedfish,"gumbel",start=list(a=-3,b=3))
summary(fitsfg)

cdfcompcens(list(fitsfn,fitsfl,fitsfg))
cdfcompcens(list(fitsfn,fitsfl,fitsfg),datacol="orange",
    legendtext=c("normal","logistic","Gumbel"),
    main="bacterial contamination fits",
    xlab="bacterial concentration (CFU/g)",ylab="F")
cdfcompcens(list(fitsfn,fitsfl,fitsfg),datacol="orange",
    legendtext=c("normal","logistic","Gumbel"),
    main="bacterial contamination fits",
    xlab="bacterial concentration (CFU/g)",ylab="F",
    xlegend = "center")

# (2) Same plot in x logscale
#
cdfcompcens(list(fitsfn,fitsfl,fitsfg),xlog = TRUE)

Run the code above in your browser using DataLab