Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: New package -diptest- available from SSC for assessing modality


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: New package -diptest- available from SSC for assessing modality
Date   Tue, 3 Feb 2009 19:40:42 -0000

Thanks to Kit Baum as usual, a new package -diptest- is now available
from SSC. Stata 9 is required. 

On 19 March 2008, in 

<http://www.stata.com/statalist/archive/2008-03/msg00715.html> 

Fabian Slonimczyk asked 

I need to test whether the distribution of my data is unimodal. I
found a test (Hartigan's dip test) on line but it has been programmed
for R or Matlab only. Do you know whether this or other tests have
been developed for Stata?

And I made various arm-waving comments in my reply: 

<http://www.stata.com/statalist/archive/2008-03/msg00723.html> 

For separate reasons, I got interested myself in that test, so here it
is. I remain of the view that the best single thing you could do if
seriously interested in modality is to look at estimates of the density
function, which is hardly surprising as that advice is widely given. But
this test is interesting, not least because the test statistic is itself
a measure of departure from unimodality. 

A digest follows my signature. The full references are in the help file.

I should flag that my Mata code is based on the original Fortran code of
Pamela Hartigan and the C code of Martin Maechler behind his R package.
Still, the translation is to be blamed on me.... Yet this Stata
implementation does something in neither, simulate as well to get a
P-value. 

Nick 
[email protected] 

diptest Stata module for dip statistic to test for unimodality

-diptest- calculates and displays the dip statistic to test for
unimodality. This statistic is the maximum difference between the
empirical distribution function and the unimodal distribution function
that minimises that maximum difference.
The dip thus measures departure of a sample from unimodality and was
proposed by Hartigan and Hartigan (Annals of Statistics
1985) as a test statistic for unimodality. Hartigan (Applied Statistics
1985) published Fortran code. Maechler (2003) published corrected C code
as part of an R package diptest. The reference distribution for
calculating the dip statistic is the uniform, as a worst case unimodal
distribution. P-values are calculated by comparing the dip statistic
obtained with those for repeated 
samples of the same size from a uniform distribution.        


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index