Learn R Programming

NPCirc (version 3.2.1)

modal.clustering: Unsupervised clustering for circular or axial data

Description

Performs nonparametric modal clustering for circular or axial data using kernel density estimation. Observations are assigned to clusters according to the modes of the estimated density, without requiring the number of clusters to be specified in advance.

Usage

modal.clustering(x,bw=NULL,tol=0.0000000000001, plot=TRUE,shrink = 1, pch=16, 
      col.points="grey",stack=TRUE, labels=NULL, control.circular = list())

Value

A list with the following components:

modes

Numeric vector containing the estimated mode locations (in the same units as the input data).

bw

Smoothing parameter used for mode estimation.

clust

An integer vector assigning each observation in x to a cluster. Observations assigned the same number belong to the same cluster.

Arguments

x

Data from which the modes are to be estimated. The object is coerced to class circular.

bw

Smoothing parameter for the von Mises kernel for the estimation of the modes. If null, bw.AA with the option deriv=1 is used.

tol

Numeric tolerance used in the mode estimation algorithm to determine convergence. Smaller values yield more precise but potentially slower computations.

plot

Logical; if TRUE, a plot of the estimated density and detected modes is produced.

shrink

Positive numeric value controlling the radial scaling of stacked points in the plot. Only used if plot = TRUE.

pch

Plotting character for the data points (see graphical parameter pch). Only used if plot = TRUE.

col.points

Color of the data points. Can be specified as a character string or numeric index. Only used if plot = TRUE.

stack

Logical; if TRUE, observations are stacked radially in the plot to reduce overlap. Only used if plot = TRUE.

labels

Logical; if TRUE, angular reference labels are added to the plot.

control.circular

A list of control parameters passed to circular::circular to define properties such as units, zero direction, and rotation.

Author

Maria Alonso-Pena

Details

The function performs nonparametric mode-based clustering for circular or axial data using kernel density estimation. The circular mean-shift algorithm is initialized with all sample points as starting values. Points that converge to the same mode are assigned to the same cluster, providing a fully data-driven clustering solution without requiring the number of clusters to be specified in advance.

The bandwidth parameter (bw) controls the smoothness of the estimated density and strongly influences the number of detected modes. If bw=NULL, the bandwidth is selected as a plug-in of the optimal bandwidth for the estimation of the first derivative. The tol argument defines the numerical tolerance for convergence in the mode-seeking algorithm.

When plot = TRUE, the estimated density and detected modes are displayed in a circular plot. Data points can be optionally stacked radially (stack) to reduce overlap, and their appearance can be customized through pch, col.points, and shrink. Angular reference labels can be added using labels. Only the plotting-related arguments are used when plot = TRUE.

The control.circular list can be used to specify properties of the circular or axial data, such as units, zero direction, and rotation, ensuring that calculations respect the geometry of the sample.

References

Alonso-Pena, M., Aerden, D.G.A.M. and Angulo, J.M. (2026). Quantifying tectonic relevance of porphyroblast inclusion trails: axial mode estimation and clustering.

Examples

Run this code
# \donttest{
# axial data in degrees, geographics template
set.seed(1)
x<-c(rvonmises(100,pi/8,10),rvonmises(100,pi,5))
x<-conversion.circular(x/2,units="degrees",template="geographics",modulo="pi")

plot(x,stack=TRUE)
points(x+180,stack=TRUE,col="grey")

modal.clustering(x,col.points="grey80")

# }

Run the code above in your browser using DataLab