32
$\begingroup$

I would like to find a way to quantify the intensity of bimodality of some distributions I got empirically. From what I read, there is still some debate about the way to quantify bimodality. I chose to use Hartigans' dip test which seems to be the only one available on R (original paper : http://www.stat.washington.edu/wxs/Stat593-s03/Literature/hartigan85a.pdf). Hartigans' dip test is defined as : "The dip test measures multimodality in a sample by the maximum difference, over all sample points, between the empirical distribution function, and the unimodal distribution function that minimizes that maximum difference".

I would like to understand completely how I should interpret this statistics before using it. I was expecting that the dip test would increase if the distribution is multimodal (as it is defined as "the maximum difference from the unimodal distribution"). But : you can read in the wikipedia page about multimodal distribution that "Values less than 0.05 indicate significant bimodality and values greater than 0.05 but less than 0.10 suggest bimodality with marginal significance.". Such statement comes from this paper (Fig. 2). According this paper, the dip test index is close to 0 when the distribution is bimodal. It confuses me.

To interpret correctly the Hartigans' dip test I constructed some distributions (the original code is from here) and I increased the value of exp(mu2) (called 'Intensity of bimodularity' from now on - Edit : I should have called it 'Intensity of bimodality') to get bimodality. In the first graph, you can see some example of distributions. Then I estimated the diptest index (second graph) and the p value (third graphe) associated (package diptest) to those different simulated distributions. The R code used is at the end of my post.

What I show here is that the dip test index is high and the Pvalue is low when the distibutions are bimodal. Which is contrary to what you can read on the internet.

I am no expert in statistics, so that I barely understood Hartigans' paper. I would like to get some comments about the right way we should interpret Hartigans' dip test. Am I wrong somewhere ?

Thank you all. Regards,

T.A.

Example of distribution simulated : Example of distribution simulated

Hartigan's dip test index associated : enter image description here

Hartigan's dip test p.value associated : enter image description here

library(diptest)
library(ggplot2)


# CONSTANT PARAMETERS
sig1 <- log(3)
sig2 <- log(3)
cpct <- 0.5
N=1000

#CREATING BIMOD DISTRIBUTION
bimodalDistFunc <- function (n,cpct, mu1, mu2, sig1, sig2) {
  y0 <- rlnorm(n,mean=mu1, sd = sig1)
  y1 <- rlnorm(n,mean=mu2, sd = sig2)

  flag <- rbinom(n,size=1,prob=cpct)
  y <- y0*(1 - flag) + y1*flag 
}

#DIP TEST
DIP_TEST <- function(bimodalData) {
  TEST <- dip.test(bimodalData)
  return(TEST$statistic[[1]])   # return(TEST$p.value[[1]])    to get the p value
}
DIP_TEST(bimodalData)


# SIMULATION
exp_mu1 = 1
max_exp_mu2 = 100
intervStep = 100
repPerInt = 10

# single distibutions
expMu2Value <- c()
bimodalData <- c()
mu1 <- log(exp_mu1)   
mu2 <- log(exp_mu1)
bimodalData <- c(bimodalData,log(bimodalDistFunc(n=N,cpct,mu1,mu2, sig1,sig2)))
expMu2Value <- c(expMu2Value,rep(exp_mu1,length(log(bimodalDistFunc(n=N,cpct,mu1,mu2, sig1,sig2)))))

mu1 <- log(exp_mu1)   
mu2 <- log(max_exp_mu2)
bimodalData <- c(bimodalData,log(bimodalDistFunc(n=N,cpct,mu1,mu2, sig1,sig2)))
expMu2Value <- c(expMu2Value,rep(max_exp_mu2,length(log(bimodalDistFunc(n=N,cpct,mu1,mu2, sig1,sig2)))))

mu1 <- log(exp_mu1)   
mu2 <- log(trunc((max_exp_mu2-exp_mu1)/2+1))
bimodalData <- c(bimodalData,log(bimodalDistFunc(n=N,cpct,mu1,mu2, sig1,sig2)))
expMu2Value <- c(expMu2Value,rep(trunc((max_exp_mu2-exp_mu1)/2+1),length(log(bimodalDistFunc(n=N,cpct,mu1,mu2, sig1,sig2)))))

tableExamples <- data.frame(expMu2Value,bimodalData)
tableExamples$expMu2Value <- as.factor(tableExamples$expMu2Value)
ExamplePlot <- ggplot(tableExamples)+
  geom_histogram(aes(bimodalData),color='white')+
  ylab("Count")+
  xlab("")+
  facet_wrap(~expMu2Value)+
  ggtitle("Intensity of bimodularity")

# calculation of the dip test index
exp_mu2Int = seq(from=exp_mu1,to=max_exp_mu2,length.out=intervStep)
expmu2Vec = c()
dipStat = c()
testDone = c()
for(exp_mu2 in exp_mu2Int){
  mu1 <- log(exp_mu1)   
  mu2 <- log(exp_mu2)
  for(rep in 1:repPerInt){
    bimodalData <- log(bimodalDistFunc(n=N,cpct,mu1,mu2, sig1,sig2))
    diptestone = DIP_TEST(bimodalData)
    expmu2Vec = c(expmu2Vec,exp_mu2)
    dipStat = c(dipStat,diptestone)
    testDone = c(testDone,"diptest")
  }
}
table = data.frame(expmu2Vec,dipStat,testDone)

IndexPlot <- ggplot(table)+
  geom_point(aes(expmu2Vec,dipStat,color=testDone))+
  ylab("Index")+
  xlab("Intensity of Bimodularity")+
  scale_color_discrete(name="Test")

ExamplePlot
IndexPlot
$\endgroup$
14
  • 4
    $\begingroup$ Very thorough question work up about a topic that is arcane by any statistician's standards. The obvious first questions, before one even gets into interpretation is, "Why do you need this test? What information is it intended to communicate?" Can provide some additional context for the motivations that have led you to the much, much further downstream issue of the interpretation of the results from the "dip test?" In other words, other than it's convenience wrt R programming, what path of logic has led you to the "dip test" in the first place? $\endgroup$
    – user78229
    Commented Jun 13, 2015 at 16:00
  • 1
    $\begingroup$ Thank you for you answer, Mike. I'm working on a theoretical model in evolutionary biology and I am carrying out a sensitivity analysis. In particular, I observe that varying some parameters modify the distribution of a output variable from unimodal to bimodal (which is actually very interesting). That's why I'm looking for a simple statistics to describe the multimodularity of a distribution. It would allow me to focus the sensitivity analysis on the multimodularity. $\endgroup$
    – T.A.
    Commented Jun 13, 2015 at 17:00
  • $\begingroup$ I found out that the dip test could be easily calculated in R and that it could quantify the deviance from a unimodal distribution. Of course, I would be really interested by any other statistics describing the multimodularity of a distribution. $\endgroup$
    – T.A.
    Commented Jun 13, 2015 at 17:00
  • $\begingroup$ Hmmm...fitting a few humble polynomials could amount to a "poor man's" approach to dealing with the curvilinearity you're observing and might be more readily deployed and interpreted than Hartigan's test. You don't say whether your issues include dealing with any growth functions. For instance, in human development, there are several well-known "bumps" in the growth trajectory at distinct points of the life cycle. Nonparametric models have been found to better fit and approximate these nonlinearities than parametric models. $\endgroup$
    – user78229
    Commented Jun 13, 2015 at 17:33
  • 3
    $\begingroup$ On the statistical issues: As said, the dip test takes unimodality as a reference. I don't think departures from it can be interpreted in terms of the number of modes just from the P-value. I've found it immensely more useful to interpret number of modes with a combination of density estimation and substantive interpretation. $\endgroup$
    – Nick Cox
    Commented Jun 13, 2015 at 17:54

1 Answer 1

17
$\begingroup$

Mr. Freeman (author of the paper I told you about) told me that he was actually looking only at the Pvalue of the dip test. This confusion comes from his sentence :
"HDS values range from 0 to 1 with values less than .05 indicating significant bimodality, and values greater than .05 but less than .10 suggesting bimodality with marginal significance". HDS values corresponds to the Pvalue, and not the dip test statistics. It was unclear in the paper.

My analysis is good : the dip test statistics increases when the distribution is deviant from a unimodal distribution.

Bimodality test and Silverman's test can also be computed easily in R and do the job well.

$\endgroup$
4
  • 2
    $\begingroup$ Please register & merge your accounts. You can find information about how to do this in the My Account section of our help center. $\endgroup$ Commented Jun 18, 2015 at 14:06
  • 1
    $\begingroup$ The link to the paper is missing? Also, indicating its title, rather than a private message like "the paper I told you about", might be more useful ;-) $\endgroup$
    – Matifou
    Commented Jul 31, 2022 at 9:38
  • $\begingroup$ I found "the paper" (with quite some effort); found it on https://www.freemanlab.org/publications under 2013 : Freeman, J.B. & Dale, R. (2013). Assessing Bimodality to Detect the Presence of a Dual Cognitive Process. Behavior Research Methods, 45 (1), 83-97. $\endgroup$ Commented Jul 30 at 13:04
  • $\begingroup$ The link PDF there, still works $\endgroup$ Commented Jul 30 at 13:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.