dip

0th

Percentile

Compute Hartigan's Dip Test Statistic for Unimodality

Computes Hartigan's dip test statistic for testing unimodality, and additionally the modal interval.

Keywords
distribution, htest
Usage
dip(x, full.result = FALSE, debug = FALSE)
Arguments
x
numeric; the data.
full.result
logical; if TRUE returns the full result list, see below.
debug
logical; if true, some tracing information is printed (from the C routine).
Value

  • depending on full.result either a number, the dip statistic, or a list with components
  • xthe sorted unname()d data.
  • nlength(x).
  • dipthe dip statistic
  • lo.hiindices into x for lower and higher end of modal interval
  • xl, xulower and upper end of modal interval
  • gcm, lcm(last used) indices for greatest convex minorant and the least concave majorant.
  • mn, mjindex vectors of length n for the GC minorant and the LC majorant respectively.

Note

For $n \le 3$ where n <- length(x), the dip statistic is always zero, i.e., there's no possible dip test.

Yong Lu lyongu+@cs.cmu.edu found in Oct 2003 that the code wasn't giving symmetric results for mirrored data (and was giving results of almost 1, and then found the reason, a misplaced ")" in the original Fortran code. This bug has been corrected for diptest version 0.25-0.

References

P. M. Hartigan (1985) Computation of the Dip Statistic to Test for Unimodality; Applied Statistics (JRSS C) 34, 320--325.

J. A. Hartigan and P. M. Hartigan (1985) The Dip Test of Unimodality; Annals of Statistics 13, 70--84.

See Also

isoreg for isotonic regression.

Aliases
  • dip
Examples
data(statfaculty)
plot(density(statfaculty))
dip(statfaculty)

str(dip(statfaculty, full = TRUE, debug = TRUE))

data(faithful)
fE <- faithful$eruptions
plot(density(fE))
str(dip(fE, full = TRUE, debug = TRUE))

data(precip)
plot(density(precip))
str(dip(precip, full = TRUE, debug = TRUE))
Documentation reproduced from package diptest, version 0.25-0, License: GPL version 2 or later

Community examples

Looks like there are no examples yet.