# Test for bimodal distribution

I wonder if there is any statistical test to "test" the significance of a bimodal distribution. I mean, How much my data meets the bimodal distribution or not? If so, is there any test in the R program?

• Did you not find an answer by searching our site? If not, what is lacking? – whuber Feb 28 '13 at 18:43
• There are tests for bimodality or multimodality, but they tend to be one-sided. That is, you can conclude stuff like "there's more than one mode", but you can't say "there's fewer than three modes" - you can get lower bounds on the number of modes but you can't really get upper bounds because a multimodal distribution with any number of modes can be found that is arbitrarily close to a distribution with any smaller number of modes. I will see if I can dig up some explicit tests or references. – Glen_b -Reinstate Monica Feb 28 '13 at 22:25
• The wikipedia page on bimodal distribution lists eight tests for multimodality against unimodality and supplies references for seven of them. I am not sure if any are in R. I will look. – Glen_b -Reinstate Monica Feb 28 '13 at 22:31

Another possible approach to this issue is to think about what might be going on behind the scenes that is generating the data you see. That is, you can think in terms of a mixture model, for example, a Gaussian mixture model. For instance, you might believe that your data are drawn from either a single normal population, or from a mixture of two normal distributions (in some proportion), with differing means and variances. Of course, you don't have to believe that there are only one or two, nor do you have to believe that the populations from which the data are drawn need to be normal.

There are (at least) two R packages that allow you to estimate mixture models. One package is flexmix, and another is mclust. Having estimated two candidate models, I believe it may be possible to conduct a likelihood ratio test. Alternatively, you could use the parametric bootstrap cross-fitting method (pdf).

• Hi @gung, for the parametric bootstrap cross-fitting method, how would you define the optimal criterion with respect to bimodal distribution? There may be a case where two competing distributions cross each other at two points. What should be done in such a case? – akashrajkn Nov 5 '15 at 8:26

As mentioned in comments, the Wikipedia page on 'Bimodal distribution' lists eight tests for multimodality against unimodality and supplies references for seven of them.

There are at least some in R. For example:

1. The package diptest implements Hartigan's dip test.

2. The stamp data in the bootstrap package was used in Efron and Tibshirani's Introduction to the Bootstrap (the book on which the package is based) to do an example relating to bootstrapping on the number of modes; if you have access to the book you might be able to use that approach.

Efron, B. and Tibshirani, R. (1993) An Introduction to the Bootstrap.
Chapman and Hall, New York, London.

--

There's a question on CV that talks about identifying (i.e., estimating rather than testing) the number of modes which @whuber's search turns up. It's worth reading the answers there. One of the responses there (mine, as it happens) has a link to a Google search which turns up this paper by David Donoho on constructing one-sided CIs for the number of modes, which can of course be used as a test (e.g., if the one-sided interval doesn't include the unimodal case, you can reject unimodality). To the best of my knowledge that isn't one of the tests that Wikipedia mentions. I don't think there's an R implementation of that interval, but (in spite of the fact that Donoho tends to use fairly sophisticated tools in his discussion of it) it's actually a pretty simple idea to implement. That idea is directly related to the notion of using kernel density estimation.

• That's valuable work. – rolando2 Feb 28 '13 at 23:28