Learn R Programming

fitdistrplus (version 0.3-4)

cdfcomp: Compares various fitted distributions to data on a cdf plot

Description

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

Usage

cdfcomp(ft,xlogscale=FALSE,addlegend=TRUE,legendtext,
datapch,datacol,fitcol,fitlty,xlab,ylab,xlim,
main,xlegend = "bottomright",ylegend = NULL,horizontals = TRUE, 
verticals = FALSE, ...)

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
datapch
An integer specifying a symbol to be used in plotting data points (ecdf)
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
xlim
numeric vectors of length 2, giving the x coordinates range
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.
horizontals
If TRUE, draws horizontal lines for step empirical cdf function
verticals
If TRUE, draws also vertical lines for step empirical cdf function. Only taken into account if horizontals is TRUE
...
further graphical arguments passed to graphical functions used in cdfcomp

Details

Empirical and theoretical distributions are simply plotted in cdf. By default a legend is added to the plot. Arguments legendtext,datapch,datacol,fitcol,fitlty,xlab,ylab,xlim,main,xlegend,ylegend are optional and fixed to default values if omitted.

See Also

plotdist, legend.

Examples

Run this code
# (1) Plot various distributions fitted to serving size data
#
data(groundbeef)
serving <- groundbeef$serving
fitW <- fitdist(serving,"weibull")
fitln <- fitdist(serving,"lnorm")
fitg <- fitdist(serving,"gamma")
cdfcomp(list(fitW,fitln,fitg),horizontals = FALSE)
cdfcomp(list(fitW,fitln,fitg),horizontals = TRUE)
cdfcomp(list(fitW,fitln,fitg),horizontals = TRUE, verticals=TRUE,datacol="orange")
cdfcomp(list(fitW,fitln,fitg),legendtext=c("Weibull","lognormal","gamma"),
    main="ground beef fits",xlab="serving sizes (g)",
    ylab="F",xlim = c(0,250))
cdfcomp(list(fitW,fitln,fitg),legendtext=c("Weibull","lognormal","gamma"),
    main="ground beef fits",xlab="serving sizes (g)",
    ylab="F",xlim = c(0,250),xlegend = "topleft")


# (2) Plot in of lognormal distributions fitted by 
# maximum goodness-of-fit estimation
# using various distances (data plotted in log scale)
#
data(endosulfan)
ATV <-subset(endosulfan,group == "NonArthroInvert")$ATV
flnMGEKS <- fitdist(ATV,"lnorm",method="mge",gof="KS")
flnMGEAD <- fitdist(ATV,"lnorm",method="mge",gof="AD")
flnMGEADL <- fitdist(ATV,"lnorm",method="mge",gof="ADL")
flnMGEAD2L <- fitdist(ATV,"lnorm",method="mge",gof="AD2L")
cdfcomp(list(flnMGEKS,flnMGEAD,flnMGEADL,flnMGEAD2L),
xlogscale=TRUE,main="fits of a lognormal dist. using various GOF dist.",
legendtext=c("MGE KS","MGE AD","MGE ADL","MGE AD2L"))
cdfcomp(list(flnMGEKS,flnMGEAD,flnMGEADL,flnMGEAD2L),
xlogscale=TRUE,verticals=TRUE,xlim=c(10,100000))

Run the code above in your browser using DataLab