CDF: CDF plots the empirical and theoretical cumulative...

Description Usage Arguments Details Value Author(s) Examples

Description

computes and plots the empirical cumulative distribution function (ecdf). Also plots models over the ecdf

Usage

1
2
3
CDF(x, distr = NULL, para = NULL, xlim = NULL, main = "CDF",
  xlab = NULL, ylab = NULL, col = "lightgray", pch = 20, cex = 1.8,
  lcol = par("col"), lty = par("lty"), lwd = par("lwd"), ...)

Arguments

x

a vector of values for which the histogram is desired.

distr

a character string of the distribution name. See the examples below and ?distributions. Default to NULL to plot just the empirical DCF.

para

A named list giving the parameters of the named distribution. Default to NULL to plot just the empirical DCF

xlim

the x limits (x1, x2) of the plot. x1 > x2.

main

a main title for the plot, see also title. Default to "CDF".

xlab

a label for the x axis, defaults to a description of x.

ylab

a label for the y axis, defaults to "CDF".

col

a character string of the points color. See ?par

pch

character style. Default to 20. see points.default

cex

Magnification of points. Defatult to 1.8

lcol

a character string of the line color of the model curve. See "col" in ?par

lty

a character string of the line type of the model curve. See ?par

lwd

a character string of the line width of the model curve. See ?par

...

further arguments passed to plot

Details

This function is based on the function plotdist from the package fitdistrplus

Value

a list with: CDF. A data.frame with the sorted input values in the first column and the CDF values in the second column xlim. A vector with the limits of the x axis

Author(s)

Francisco Mendoza-Torres (mentofran@gmail.com)

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
# EXAMPLE 1: NORMAL DISTRIBUTION (EMPIRICAL CDF)
set.seed(123)
MEAN <- 2
SD <- 0.5
X <- rnorm(n = 300, mean = MEAN, sd = SD)
Results <- CDF(x = X, main = "Empirical CDF") # Empirical CDF

# EXAMPLE 2: NORMAL DISTRIBUTION (MODEL OVER THE EMPIRICAL CDF)
PARA <- list(mean = MEAN, sd = SD)
Results <- CDF(x = X, distr = "norm", para = PARA)
CDF(x = X, distr = "norm", para = PARA, col = "orange")
CDF(x = X, distr = "norm", para = PARA, col = "orange", main = "Test Main")
CDF(x = X, distr = "norm", para = PARA, col = "orange", main = "Test Main", pch = "i")
CDF(x = X, distr = "norm", para = PARA, col = "orange", main = "Test Main", pch = "i",
    lcol = "blue", lwd = 3)

# EXAMPLE 3: EXPONENTIAL DISTRIBUTION
set.seed(123)
RATE <- 0.5
X <- rexp(300, RATE)
PARA <- list(rate = RATE)
Results <- CDF(x = X, distr = "exp", para = PARA)

mathphysmx/bernstein documentation built on Sept. 3, 2019, 12:57 p.m.