Solved – Hartigan’s dip test significant for bimodality with clearly unimodal data

distributionsmoder

I have used the following data x to check whether my results produced by Hartigan's dip test are ok or not. But the data I used suggest a unimodal distribution while Hartigan's test indicates that the distribution is not unimodal.

Now what to do. Am I not understanding it?

x = c(1,1,1,2,2,2,2,2,2.5,2.5,2.5)
hist(x)
dip.test(x)
# 
#   Hartigans' dip test for unimodality / multimodality
# 
# data:  x
# D = 0.13636, p-value = 0.04419
# alternative hypothesis: non-unimodal, i.e., at least bimodal

Best Answer

The Hartigan dip test (Hartigan and Hartigan, 1985 [1]) is for continuous distributions, or at most a mixed distribution with a single jump in the cdf at the mode. As they explain in the paper:

A unimodal F may have an atom only at a unique mode

As a result you would not expect it to work for a distribution with multiple atoms, as the one from which your sample was (at least notionally) drawn must be. In particular it wouldn't be expected to work well for discrete distributions.

[1] J. A. Hartigan and P. M. Hartigan (1985),
"The Dip Test of Unimodality"
Ann. Statist., Volume 13, Number 1, 70-84.
http://projecteuclid.org/euclid.aos/1176346577 (open access link)