pvaldistance: Distance Measures of Empirical Probability Functions

Description Usage Arguments Details Value Note See Also Examples

View source: R/pvaldistance.R

Description

This function provides a framework to evaluate various measures of distance between an empirical distribution (induced by the dataset provided) and a theoretical probability distribution.

Usage

1
pvaldistance(x, method = c("ks", "cvm"), dist.to = c("uniform"))

Arguments

x

a numeric vector containing a data sample.

method

a character string indicating which measure of distance is computed.

dist.to

a character string determining the (theoretical) probability distribution that is used as a reference.

Details

method = "ks" gives the Kolmogorov-Smirnov distance.

method = "cvm" yields the Cramér-von-Mises criterion (scaled with the sample size).

Value

A positive real number giving the distance measure.

Note

At the moment, dist.to = "uniform" (the uniform distribution on the unit interval) is the only valid option for the theoretical distribution, and hence the members of x have to lie in the unit interval.

See Also

See ks.test for the Kolmogorov-Smirnov test.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
# A sample from the standard uniform distribution
x <- runif(100, 0, 1)

# Distance to uniformity should be small
pvaldistance(x, "ks")
pvaldistance(x, "cvm")

# A sample from the Beta(2, 7) distribution
y <- rbeta(100, 2, 7)

# Distance to uniformity should be much larger here
pvaldistance(y, "ks")
pvaldistance(y, "cvm")

bootruin documentation built on May 2, 2019, 10:23 a.m.