Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

ks.plot.unif

Plot the ECDF of a uniform sample with Kolmogorov-Smirnov bounds


Description

This plot function takes a univariate sample that should be tested for a U(0,1) distribution, plots its empirical cumulative distribution function (ecdf), and adds a confidence band by inverting the corresponding Kolmogorov-Smirnov test (ks.test). The uniform distribution is rejected if the ECDF is not completely inside the confidence band.

Usage

ks.plot.unif(U, conf.level = 0.95, exact = NULL,
             col.conf = "gray", col.ref = "gray",
             xlab = expression(u[(i)]), ylab = "Cumulative distribution")

Arguments

U

numeric vector containing the sample. Missing values are (silently) ignored.

conf.level

confidence level for the K-S-test (defaults to 0.95), can also be a vector of multiple levels.

exact

see ks.test.

col.conf

colour of the confidence lines.

col.ref

colour of the diagonal reference line.

xlab, ylab

axis labels.

Value

NULL (invisibly).

Author(s)

Michael Höhle and Sebastian Meyer.

The code contains segments originating from the source of the ks.test function https://svn.R-project.org/R/trunk/src/library/stats/R/ks.test.R, which is Copyright (C) 1995-2012 The R Core Team available under GPL-2 (or later) and C functionality from https://svn.R-project.org/R/trunk/src/library/stats/src/ks.c, which is copyright (C) 1999-2009 the R Core Team and available under GPL-2 (or later). Somewhat hidden in their ‘ks.c’ file is a statement that part of their code is based on code published in Marsaglia et al. (2003).

References

George Marsaglia and Wai Wan Tsang and Jingbo Wang (2003): Evaluating Kolmogorov's distribution. Journal of Statistical Software, 8 (18). doi: 10.18637/jss.v008.i18

See Also

ks.test for the Kolmogorov-Smirnov test, as well as checkResidualProcess, which makes use of this plot function.

Examples

samp <- runif(99)
ks.plot.unif(samp, conf.level=c(0.95, 0.99), exact=TRUE)
ks.plot.unif(samp, conf.level=c(0.95, 0.99), exact=FALSE)

surveillance

Temporal and Spatio-Temporal Modeling and Monitoring of Epidemic Phenomena

v1.19.1
GPL-2
Authors
Michael H<f6>hle [aut, ths] (<https://orcid.org/0000-0002-0423-6702>), Sebastian Meyer [aut, cre] (<https://orcid.org/0000-0002-1791-9449>), Michaela Paul [aut], Leonhard Held [ctb, ths], Howard Burkom [ctb], Thais Correa [ctb], Mathias Hofmann [ctb], Christian Lang [ctb], Juliane Manitz [ctb], Andrea Riebler [ctb], Daniel Saban<e9>s Bov<e9> [ctb], Ma<eb>lle Salmon [ctb], Dirk Schumacher [ctb], Stefan Steiner [ctb], Mikko Virtanen [ctb], Wei Wei [ctb], Valentin Wimmer [ctb], R Core Team [ctb] (A few code segments are modified versions of code from base R)
Initial release
2021-03-30

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.