Hartigan's Dip Test Statistic for Unimodality: R Package and Usage, Exams of Statistics

Information about the 'diptest' r package, which includes hartigan's dip test statistic for unimodality and related functions. The package can be used to test the unimodality of a dataset and determine the modal interval. Usage examples and references to the original research papers.

Typology: Exams

Pre 2010

Uploaded on 08/31/2009

koofers-user-zma
koofers-user-zma 🇺🇸

5

(1)

10 documents

1 / 6

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Package ‘diptest’
April 17, 2009
Version 0.25-2
Date 2009-02-09
lastDate 2004-08-12
Title Hartigan’s dip test statistic for unimodality - corrected code
Description Compute Hartigan’s dip test statistic for unimodality
Maintainer Martin Maechler <[email protected]>
LazyData yes
Author Martin Maechler, based on Fortran and S-plus from Dario Ringach (NYU.edu)
License GPL (>= 2)
Repository CRAN
Date/Publication 2009-02-09 18:37:51
Rtopics documented:
dip.............................................. 2
exHartigan.......................................... 3
qDiptab ........................................... 4
statfaculty.......................................... 5
Index 6
1
pf3
pf4
pf5

Partial preview of the text

Download Hartigan's Dip Test Statistic for Unimodality: R Package and Usage and more Exams Statistics in PDF only on Docsity!

Package ‘diptest’

April 17, 2009

Version 0.25-

Date 2009-02-

lastDate 2004-08-

Title Hartigan’s dip test statistic for unimodality - corrected code

Description Compute Hartigan’s dip test statistic for unimodality

Maintainer Martin Maechler

LazyData yes

Author Martin Maechler, based on Fortran and S-plus from Dario Ringach (NYU.edu)

License GPL (>= 2)

Repository CRAN

Date/Publication 2009-02-09 18:37:

R topics documented:

dip.............................................. 2 exHartigan.......................................... 3 qDiptab........................................... 4 statfaculty.......................................... 5

Index 6

2 dip

dip Compute Hartigan’s Dip Test Statistic for Unimodality

Description

Computes Hartigan’s dip test statistic for testing unimodality, and additionally the modal interval.

Usage

dip(x, full.result = FALSE, debug = FALSE)

Arguments

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).

Value

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.

Note

For n ≤ 3 where n <- length(x), the dip statistic is always zero, i.e., there’s no possible dip test. Yong Lu 〈[email protected]〉 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.

Author(s)

Martin Maechler 〈[email protected]〉, based on earlier code from Dario Ringach 〈[email protected]

4 qDiptab

qDiptab Table of Quantiles from a Large Simulation for Hartigan’s Dip Test

Description

Whereas Hartigan(1985) published a table of empirical percentage points of the dip statistic (see dip) based on N=9999 samples of size n from U [0, 1], our table of empirical quantiles is currently based on N=1’000’001 samples for each n.

Format

A numeric matrix where each row corresponds to sample size n, and each column to a probability (percentage) in [0, 1]. The dimnames are named n and Pr and coercable to these values, see the ex- amples. attr(qDiptab, "N_1") is N − 1 , such that with k <- as.numeric(dimnames(qDiptab)$Pr)

  • attr(qDiptab,^ "N_1"), e.g.,^ qDiptab[n == 15,]^ contains exactly the order statis- tics D[k] (from the N + 1 simulated values of dip(U), where U <- runif(15).

Note

Taking N=1’000’001 ensures that all the quantile(X, p) used here are exactly order statistics sort(X)[k].

Author(s)

Martin Maechler 〈[email protected]

See Also

dip, also for the references.

Examples

data(qDiptab) str(qDiptab)

the sample sizes `n' :

dnqd <- dimnames(qDiptab) (nn <- as.integer(dnqd $n))

the probabilities:

P.p <- as.numeric(print(dnqd $ Pr))

This is as "Table 1" in Hartigan & Hartigan (1985) -- but more accurate

ps <- c(1,5,10,50,90,95,99, 99.5, 99.9)/ tab1 <- qDiptab[nn <= 200, as.character(ps)] round(tab1, 4)

statfaculty 5

statfaculty Faculty Quality in Statistics Departments

Description

Faculty quality in statistics departments was assessed as part of a larger study reported by Scully(1982).

Usage

data(statfaculty)

Format

A numeric vector of 63 (integer) numbers, sorted increasingly, as reported by the reference.

Source

M. G. Scully (1982) Evaluation of 596 programs in mathematics and physical sciences; Chronicle Higher Educ. 25 5, 8–10.

References

J. A. Hartigan and P. M. Hartigan (1985) The Dip Test of Unimodality; Annals of Statistics 13 , 70–84.

Examples

data(statfaculty) plot(dH <- density(statfaculty)) rug(jitter(statfaculty))