modeHunting: Multiscale analysis of a density on all possible intervals

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

View source: R/modeHunting.r


Simultanous confidence statements for the existence and location of local increases and decreases of a density f, computed on all intervals spanned by two observations.


modeHunting(X.raw, lower = -Inf, upper = Inf, crit.vals, = FALSE)



Vector of observations.


Lower support point of f, if known.


Upper support point of f, if known.


2-dimensional vector giving the critical values for the desired level.

If = TRUE, the set of minimal intervals is output, otherwise all intervals with a test statistic above the critical value are given.


In general, the methods modeHunting, modeHuntingApprox, and modeHuntingBlock compute for a given level α \in (0, 1) and the corresponding critical value c_{jk}(α) two sets of intervals

\mathcal{D}^\pm(α) = \Bigl\{ \mathcal{I}_{jk} \ : \ \pm T_{jk}({\bf{X}} ) > c_{jk}(α) \Bigr\}

where \mathcal{I}_{jk}:=(X_{(j)},X_{(k)}) for 0≤ j < k ≤ n+1, k-j> 1 and c_{jk} are appropriate critical values.

Specifically, the function modeHunting computes \mathcal{D}^\pm(α) based on the two test statistics

T_n^+({\bf{X}}, \mathcal{I}) = \max_{(j,k) \in \mathcal{I}} \Bigl( |T_{jk}({\bf{X}})| / σ_{jk} - Γ \Bigl(\frac{k-j}{n+2}\Bigr)\Bigr)


T_n({\bf{X}}, \mathcal{I}) = \max_{(j,k) \in \mathcal{I}} ( |T_{jk}({\bf{X}})| / σ_{jk} ),

using the set \mathcal{I} := \mathcal{I}_{all} of all intervals spanned by two observations (X_{(j)}, X_{(k)}):

\mathcal{I}_{all} = \Bigl\{(j, \ k ) \ : \ 0 ≤ j < k ≤ n+1, \ k - j > 1\Bigr\}.

We introduced the local test statistics

T_{jk}({\bf{X}}) := ∑_{i=j+1}^{k-1} ( 2 X_{(i; j, k)} - 1) 1\{X_{(i; j, k)} \in (0,1)\},

for local order statistics

X_{(i; j, k)} := \frac{X_{(i)}-X_{(j)}}{X_{(k)} - X_{(j)}},

the standard deviation σ_{jk} := √{(k-j-1)/3} and the additive correction term Γ(δ) := √{2 \log(e / δ)} for δ > 0.

If = TRUE, the set \mathcal{D}^\pm(α) is replaced by the set {\bf{D}}^\pm(α) of its minimal elements. An interval J \in \mathcal{D}^\pm(α) is called minimal if \mathcal{D}^\pm(α) contains no proper subset of J. This minimization post-processing step typically massively reduces the number of intervals. If we are mainly interested in locating the ranges of increases and decreases of f as precisely as possible, the intervals in \mathcal{D}^\pm(α) \setminus \bf{D}^\pm(α) do not contain relevant information.



The set \mathcal{D}^+(α) (or \bf{D}^+(α)), based on the test statistic with additive correction Γ.


The set \mathcal{D}^-(α) (or \bf{D}^-(α)), based on the test statistic with Γ.


The set \mathcal{D}^+(α) (or \bf{D}^+(α)), based on the test statistic without Γ.


The set \mathcal{D}^+(α) (or \bf{D}^-(α)), based on the test statistic without Γ.


Critical values for modeHunting and some combinations of n and α are provided in the data set cvModeAll. Critical values for other values of n and α can be generated using criticalValuesAll.

Parts of this function were derived from MatLab code provided on Lutz Duembgen's webpage,


Kaspar Rufibach,,

Guenther Walther,,


Duembgen, L. and Walther, G. (2008). Multiscale Inference about a density. Ann. Statist., 36, 1758–1785.

Rufibach, K. and Walther, G. (2010). A general criterion for multiscale inference. J. Comput. Graph. Statist., 19, 175–190.

See Also

modeHuntingApprox, modeHuntingBlock, and cvModeAll.


## for examples type
help("mode hunting")
## and check the examples there

modehunt documentation built on May 2, 2019, 3:31 a.m.