Description Usage Arguments Details Author(s) References See Also Examples
cdfcomp plots the empirical cumulative distribution against fitted distribution functions,
denscomp plots the histogram against fitted density functions, 
qqcomp plots theoretical quantiles against empirical ones,
ppcomp plots theoretical probabilities against empirical ones.
Only cdfcomp is able to plot fits of a discrete distribution.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | cdfcomp(ft, xlim, ylim, xlogscale = FALSE, ylogscale = FALSE, main, xlab, ylab, 
    datapch, datacol, fitlty, fitcol, addlegend = TRUE, legendtext, 
    xlegend = "bottomright", ylegend = NULL, horizontals = TRUE, 
    verticals = FALSE, do.points = TRUE, use.ppoints = TRUE, a.ppoints = 0.5, 
    lines01 = FALSE, discrete, add = FALSE, plotstyle = "graphics", 
    fitnbpts = 101, ...)
    
denscomp(ft, xlim, ylim, probability = TRUE, main, xlab, ylab, datacol, fitlty, 
    fitcol, addlegend = TRUE, legendtext, xlegend = "topright", ylegend = NULL, 
    demp = FALSE, dempcol = "black", plotstyle = "graphics", 
    discrete, fitnbpts = 101, fittype="l", ...)
qqcomp(ft, xlim, ylim, xlogscale = FALSE, ylogscale = FALSE, main, xlab, ylab, 
    fitpch, fitcol, addlegend = TRUE, legendtext, xlegend = "bottomright", 
    ylegend = NULL, use.ppoints = TRUE, a.ppoints = 0.5, line01 = TRUE, 
    line01col = "black", line01lty = 1, ynoise = TRUE, plotstyle = "graphics", ...)
    
ppcomp(ft, xlim, ylim, xlogscale = FALSE, ylogscale = FALSE, main, xlab, ylab, 
    fitpch, fitcol, addlegend = TRUE, legendtext, xlegend = "bottomright", 
    ylegend = NULL, use.ppoints = TRUE, a.ppoints = 0.5, line01 = TRUE, 
    line01col = "black", line01lty = 1, ynoise = TRUE, plotstyle = "graphics", ...)
 | 
| ft | One  | 
| xlim | The x-limits of the plot. | 
| ylim | The y-limits of the plot. | 
| xlogscale | If  | 
| ylogscale | If  | 
| main | A main title for the plot. See also  | 
| xlab | A label for the x-axis, defaults to a description of  | 
| ylab | A label for the y-axis, defaults to a description of  | 
| datapch | An integer specifying a symbol to be used in plotting data points. 
See also  | 
| datacol | A specification of the color to be used in plotting data points.
See also  | 
| fitcol | A (vector of) color(s) to plot fitted distributions. 
If there are fewer colors than fits they are recycled in the standard fashion.
See also  | 
| fitlty | A (vector of) line type(s) to plot fitted distributions/densities. 
If there are fewer colors than fits they are recycled in the standard fashion.
See also  | 
| fitpch | A (vector of) line type(s) to plot fitted quantiles/probabilities. 
If there are fewer colors than fits they are recycled in the standard fashion.
See also  | 
| fittype | The type of plot for fitted probabilities in the case of
discrete distributions: possible types are  | 
| fitnbpts | A numeric for the number of points to compute fitted probabilities 
or cumulative probabilities. Default to  | 
| addlegend | If  | 
| legendtext | A character or expression vector of length ≥ 1 to appear
in the legend. See also  | 
| xlegend, ylegend | The x and y coordinates to be used to position the legend. 
They can be specified by keyword. 
If  | 
| horizontals | If  | 
| do.points | If  | 
| verticals | If  | 
| use.ppoints | If  | 
| a.ppoints | If  | 
| lines01 | A logical to plot two horizontal lines at  | 
| line01 | A logical to plot an horizontal line y=x for  | 
| line01col, line01lty | Color and line type for  | 
| demp | A logical to add the empirical density on the plot, using the 
 | 
| dempcol | A color for the empirical density in case it is added on the plot ( | 
| ynoise | A logical to add a small noise when plotting empirical 
quantiles/probabilities for  | 
| probability | A logical to use the probability scale for  | 
| discrete | If  | 
| add | If  | 
| plotstyle | 
 | 
| ... | Further graphical arguments passed to graphical functions used in  | 
cdfcomp provides a plot of the empirical distribution and each fitted 
distribution in cdf, by default using the Hazen's rule
for the empirical distribution, with probability points defined as 
(1:n - 0.5)/n. If discrete is TRUE, probability points 
are always defined as (1:n)/n. For large dataset (n > 1e4), no 
point is drawn but the line for ecdf is drawn instead.
Note that when horizontals, verticals and do.points are FALSE,
no empirical point is drawn, only the fitted cdf is shown.
denscomp provides a density plot of each fitted distribution
with the histogram of the data for conyinuous data. 
When discrete=TRUE, distributions are considered as discrete,
no histogram is plotted but demp is forced to TRUE
and fitted and empirical probabilities are plotted either with vertical lines
fittype="l", with single points fittype="p" or
both lines and points fittype="o".
ppcomp provides a plot of the probabilities of each fitted distribution
(x-axis) against the empirical probabilities (y-axis) by default defined as 
(1:n - 0.5)/n (data are assumed continuous). 
For large dataset (n > 1e4), lines are drawn instead of pointss and customized with the fitpch parameter.
qqcomp provides a plot of the quantiles of each theoretical distribution (x-axis)
against the empirical quantiles of the data (y-axis), by default defining
probability points as (1:n - 0.5)/n for theoretical quantile calculation 
(data are assumed continuous). 
For large dataset (n > 1e4), lines are drawn instead of points and customized with the fitpch parameter.
By default a legend is added to these plots. Many graphical arguments are optional, dedicated to personalize the plots, and fixed to default values if omitted.
Christophe Dutang, Marie-Laure Delignette-Muller and Aurelie Siberchicot.
Delignette-Muller ML and Dutang C (2015), fitdistrplus: An R Package for Fitting Distributions. Journal of Statistical Software, 64(4), 1-34.
See plot, legend, ppoints, 
plot.stepfun for classic plotting functions.
See CIcdfplot and plotdist for other plot functions
of fitdistrplus.  
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | # (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 = "purple")
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 = "center", lines01 = TRUE)
denscomp(list(fitW, fitln, fitg), legendtext = c("Weibull", "lognormal", "gamma"),
  main = "ground beef fits", xlab = "serving sizes (g)", xlim = c(0, 250), xlegend = "topright")
ppcomp(list(fitW, fitln, fitg), legendtext = c("Weibull", "lognormal", "gamma"),
  main = "ground beef fits", xlegend = "bottomright", line01 = TRUE)
qqcomp(list(fitW, fitln, fitg), legendtext = c("Weibull", "lognormal", "gamma"),
  main = "ground beef fits", xlegend = "bottomright", line01 = TRUE,
  xlim = c(0, 300), ylim = c(0, 300), fitpch = 16)
# (2) Plot 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"),
  verticals = TRUE, xlim = c(10, 100000))
qqcomp(list(flnMGEKS, flnMGEAD, flnMGEADL, flnMGEAD2L),
  main = "fits of a lognormal dist. using various GOF dist.",
  legendtext = c("MGE KS", "MGE AD", "MGE ADL", "MGE AD2L"),
  xlogscale = TRUE, ylogscale = TRUE)
ppcomp(list(flnMGEKS, flnMGEAD, flnMGEADL, flnMGEAD2L),
  main = "fits of a lognormal dist. using various GOF dist.",
  legendtext = c("MGE KS", "MGE AD", "MGE ADL", "MGE AD2L"))
# (3) Plot normal and logistic distributions fitted by 
# maximum likelihood estimation
# using various plotting positions in cdf plots
#
data(endosulfan)
log10ATV <-log10(subset(endosulfan, group == "NonArthroInvert")$ATV)
fln <- fitdist(log10ATV, "norm")
fll <- fitdist(log10ATV, "logis")
# default plot using Hazen plotting position: (1:n - 0.5)/n
cdfcomp(list(fln, fll), legendtext = c("normal", "logistic"), xlab = "log10ATV")
# plot using mean plotting position (named also Gumbel plotting position)
# (1:n)/(n + 1)
cdfcomp(list(fln, fll),legendtext = c("normal", "logistic"), xlab = "log10ATV",
  use.ppoints = TRUE, a.ppoints = 0)
    
# plot using basic plotting position: (1:n)/n
cdfcomp(list(fln, fll),legendtext = c("normal", "logistic"), xlab = "log10ATV",
  use.ppoints = FALSE)
# (4) Comparison of fits of two distributions fitted to discrete data
#
data(toxocara)
number <- toxocara$number
fitp <- fitdist(number, "pois")
fitnb <- fitdist(number, "nbinom")
cdfcomp(list(fitp, fitnb), legendtext = c("Poisson", "negative binomial"))
denscomp(list(fitp, fitnb),demp = TRUE, legendtext = c("Poisson", "negative binomial"))
denscomp(list(fitp, fitnb),demp = TRUE, fittype = "l", dempcol = "black",
        legendtext = c("Poisson", "negative binomial"))
denscomp(list(fitp, fitnb),demp = TRUE, fittype = "p", dempcol = "black",
        legendtext = c("Poisson", "negative binomial"))
denscomp(list(fitp, fitnb),demp = TRUE, fittype = "o", dempcol = "black",
        legendtext = c("Poisson", "negative binomial"))
# (5) Customizing of graphical output and use of ggplot2
#
data(groundbeef)
serving <- groundbeef$serving
fitW <- fitdist(serving, "weibull")
fitln <- fitdist(serving, "lnorm")
fitg <- fitdist(serving, "gamma")
if (requireNamespace ("ggplot2", quietly = TRUE)) {
denscomp(list(fitW, fitln, fitg), plotstyle = "ggplot")
cdfcomp(list(fitW, fitln, fitg), plotstyle = "ggplot")
qqcomp(list(fitW, fitln, fitg), plotstyle = "ggplot")
ppcomp(list(fitW, fitln, fitg), plotstyle = "ggplot")
}
# customizing graphical output with graphics
denscomp(list(fitW, fitln, fitg), legendtext = c("Weibull", "lognormal", "gamma"),
  main = "ground beef fits", xlab = "serving sizes (g)", xlim = c(0, 250),
  xlegend = "topright", addlegend = FALSE)
# customizing graphical output with ggplot2
if (requireNamespace ("ggplot2", quietly = TRUE)) {
  dcomp <- denscomp(list(fitW, fitln, fitg), legendtext = c("Weibull", "lognormal", "gamma"),
    xlab = "serving sizes (g)", xlim = c(0, 250),
    xlegend = "topright", plotstyle = "ggplot", breaks = 20, addlegend = FALSE)
  dcomp + ggplot2::theme_minimal() + ggplot2::ggtitle("Ground beef fits")
}
 | 
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.