dip {diptest} | R Documentation |
Computes Hartigan's dip test statistic for testing unimodality, and additionally the modal interval.
dip(x, full.result = FALSE, debug = FALSE)
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). |
depending on full.result
either a number, the dip statistic, or
a list with components
x |
the sorted unname() d data. |
n |
length(x) . |
dip |
the dip statistic |
lo.hi |
indices into x for lower and higher end of modal interval |
xl, xu |
lower and upper end of modal interval |
gcm, lcm |
(last used) indices for greatest convex minorant and the least concave majorant. |
mn, mj |
index vectors of length n for the GC minorant and
the LC majorant respectively. |
For n <= 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 was not 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.
Nick Cox (Durham Univ.) said (on March 20, 2008 on the Stata-list):
As it comes from a bimodal husband-wife collaboration, the name
perhaps should be “Hartigan-Hartigan dip test”, but that
does not seem to have caught on. Some of my less statistical
colleagues would sniff out the hegemony of patriarchy there, although
which Hartigan is being overlooked is not clear.
Martin Maechler maechler@stat.math.ethz.ch, based on earlier code from Dario Ringach dario@wotan.cns.nyu.edu
P. M. Hartigan (1985)
Computation of the Dip Statistic to Test for Unimodality;
Applied Statistics (JRSS C) 34, 320–325.
Corresponding (buggy!) Fortran code of ‘AS 217’ available from Statlib,
http://lib.stat.cmu.edu/apstat/217
J. A. Hartigan and P. M. Hartigan (1985) The Dip Test of Unimodality; Annals of Statistics 13, 70–84.
isoreg
for isotonic regression.
qDiptab
on how to get approximate P-values.
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))