Learn R Programming

LPCM (version 0.47-6)

ms.rep: Mean shift procedures.

Description

Functions for mean shift, iterative mean shift, and inverse mean shift.

Usage

meanshift(X, x, h)
ms.rep(X, x, h, thresh= 0.0001, iter=200)
ms.rep.min(X, x, h, thresh=0.000001, iter=200, adjust.convergence=FALSE, verbose=TRUE)

Value

The function meanshift delivers a single (vector-valued) value.

The functions ms.rep and ms.rep.min produce a list with the following items:

Meanshift.points

(called M for ms.rep.min); the trajectory of points found while proceeding from the starting value x to the mode (or antimode, respectively)

Threshold.values

These give the iteration-wise values of the relative length of the mean shift step (explained in the Note section) which are then compared to thresh.

start

The starting value.

final

The mode or antimode, respectively.

Arguments

X

data matrix or vector.

x

point from which we wish to shift to the local mean.

h

scalar or vector-valued bandwidth; see also description in ms.

thresh, iter

mean shift iterations are stopped when the mean shift length (relative to the distance of of x to the overall mean; see Note section) falls below thresh, or after iter iterations (whatever event happens first).

adjust.convergence

Only required for estimation of antimodes via ms.rep.min. See also Note section below.

verbose

Allows or suppresses text output messages.

Author

J. Einbeck. See LPCM-package for further acknowledgements.

Details

The function meanshift computes a single mean shift iteration, and ms.rep computes an iterative series of mean shift iterations. Both of these functions are rarely used on their own, but are typically called by the overarching function ms.

The function ms.rep.min implements an inverse version of the mean shift procedure which can be used for the computation of antimodes (minima of the density). The methodology has been presented in the univariate setting in Ameijeiras-Alonso and Einbeck (2023). The function has been tested to a moderate extent in two dimensions, and it can be expected to work here. It has not been tested for higher dimensions. That is, for data of dimension 3 or higher, the function may or may not produce a result which may or may not correspond to an antimode.

References

Ameijeiras-Alonso, J. and Einbeck, J. (2023). A fresh look at mean-shift based modal clustering. Advances in Data Analysis and Classification, tools:::Rd_expr_doi("10.1007/s11634-023-00575-1").

See Also

ms

Examples

Run this code
data(stamps, package="multimode")
h0 <- 0.005
hist(stamps, breaks=20)
# Take arbitrary starting value x=0.08, sitting between a mode and antimode
mode <- ms.rep(stamps, 0.08,h0)$final
antimode <- ms.rep.min(stamps, 0.08,h0, verbose=FALSE)$final
segments(mode, 0, mode, 100, col=2, lwd=3)
segments(antimode, 0, antimode,100, col=3, lwd=3)

Run the code above in your browser using DataLab