multimod1d: Measure of one-dimensional multimodality

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/oned.R

Description

A measure of one-dimensional multimodality based on p-values of the diptest. A jittering whose intensity depends on the value of discrete1d is used to prevent ties. The function dip.test from package diptest is used for calculating the p-value.

Usage

1
multimod1d(x, seed = NULL, exp = 1)

Arguments

x

A numeric vector, a numeric matrix or a data frame.

seed

An integer. The seed which is used for the jittering. If NULL, a fixed default value is used.

exp

A positive integer. Controls the sensitivity of the result with (1-p-value)^exp (see details).

Details

The specific result of the function depends on the seed, its default can be changed by setting seed. A normally distributed vector, generated by rnorm with mean=0 and sd=discrete1d(x)*sd(x,na.rm=T)/5, is added to x to break ties.

To control the sensitivity of the measure an exponent can be choosen which influences the value by (1-p-value)^exp. Higher values of exp are recommended if a data set has a huge number of multimodal variables. Higher values makes it easier to seperate clear multimodal structures from not so clear ones. For example an exponent of 10 implies a value of 0.6 when (1-p-value)^exp=0.95 (this is the value for exp=1).

Value

A single value or a vector including the results of skew1d for each variable (in case of numeric matrices or data frames). If variables from data frames are categorical, 'NA' is returned.

Author(s)

Katrin Grimm

References

M. Maechler (2015) diptest: Hartigan's Dip Test Statistic for Unimodality - Corrected. https://CRAN.R-project.org/package=diptest.

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

P. M. Hartigan (1985) Algorithm AS 217: Computation of the Dip Statistic to Test for Unimodality. Journal of the Royal Statistical Society. Series C (Applied Statistics) 34(3), 320–325.

See Also

skew1d, discrete1d, iaunivariate

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
data(Election2005)
## Not run: 
multimod <- multimod1d(Election2005)
maxv <- order(multimod,decreasing=TRUE)[1:4]
par(mfrow=c(2,2))
for(i in 1:4){
  hist(Election2005[,maxv[i]],xlab="",breaks=30,
  main=paste(names(Election2005[maxv[i]])))
}

# Explore skewness, multimodality and discreteness within interactive environment.
iaunivariate(Election2005)

## End(Not run)

mbgraphic documentation built on May 2, 2019, 2:45 a.m.