fitdistrplus (version 0.1-3)

plotdist: Plot of empirical and theoretical distributions for non-censored data

Description

Plots an empirical distribution (non-censored data) with a theoretical one if specified.

Usage

plotdist(data,distr,para,breaks="default",discrete=FALSE,...)

Arguments

data
A numeric vector.
distr
A character string "name" naming a distribution for which the corresponding density function dname, the corresponding distribution function pname and the corresponding quantile function qname
para
A named list giving the parameters of the named distribution. This argument may be omitted only if distname is omitted.
breaks
If "default" the histogram is plotted with the function hist with its default breaks definition. Else breaks is passed to the function hist. This argument is not taken into account if di
discrete
If TRUE, the distribution is considered as discrete. This argument is not taken into account if distname is defined. In this last case, the distribution is automatically assumed discrete if and only if distname is
...
further graphical arguments passed to graphical functions used in plotdist

Details

Empirical and, if specified, theoretical distributions are plotted in density and in cdf. For continuous distributions, the function hist is used with its default breaks definition if breaks is "default" or passing breaks as an argument if it differs from "default". For continuous distribution and when a theoretical distribution is specified by both arguments distname and para, Q-Q plot (plot of the quantiles of the theoretical fitted distribution (x-axis) against the empirical quantiles of the data) and P-P plot (i.e. for each value of the data set, plot of the cumulative density function of the fitted distribution (x-axis) against the empirical cumulative density function (y-axis)) are also given (Cullen and Frey, 1999). The function ppoints is used for the Q-Q plot, to generate the set of probabilities at which to evaluate the inverse distribution.

References

Cullen AC and Frey HC (1999) Probabilistic techniques in exposure assessment. Plenum Press, USA, pp. 81-159.

See Also

descdist, hist, plot, plotdistcens and ppoints.

Examples

Run this code
x1<-c(6.4,13.3,4.1,1.3,14.1,10.6,9.9,9.6,15.3,22.1,13.4,
13.2,8.4,6.3,8.9,5.2,10.9,14.4)
plotdist(x1)
plotdist(x1,col="red",type="b",pch=4)
plotdist(x1,type="s")

x2<-c(rep(4,1),rep(2,3),rep(1,7),rep(0,12))
plotdist(x2,discrete=TRUE)
plotdist(x2,"pois",para=list(lambda=mean(x2)))
plotdist(x2,"pois",para=list(lambda=mean(x2)),col="red",lwd="2")

xn<-rnorm(n=100,mean=10,sd=5)
plotdist(xn,"norm",para=list(mean=mean(xn),sd=sd(xn)))
plotdist(xn,"norm",para=list(mean=mean(xn),sd=sd(xn)),pch=16,col="green")

data(groundbeef)
plotdist(groundbeef$serving)

Run the code above in your browser using DataLab