This function applies the mean shift clustering algorithm to a functional data
object of class fdata. It uses a kernel-based approach to iteratively shift points
towards high-density regions.
Usage
fmeanshift(
fdataobj,
h = -0.15,
metric = metric.lp,
par.metric = list(lp = 2),
derr = 0.1
)Arguments
- fdataobj
An object of class
fdatacontaining the functional data to be clustered.- h
The bandwidth parameter. If
h < 0, the bandwidth is estimated using theh.defaultfunction withprob = abs(h). Defaults toh = -0.15.- metric
A function to compute the distance between elements of
fdataobj. Defaults tometric.lp.- par.metric
A list of additional parameters to be passed to the
metricfunction. By default,list(lp = 2)to compute the L2 distance.- derr
A convergence tolerance parameter used to determine when the mean shift has converged. Defaults to
derr = 0.1.
Value
A list with the following components:
- cluster
An integer vector indicating the cluster assignment for each observation in
fdataobj.- centers
An
fdataobject representing the centers of the clusters.
Details
The fmeanshift algorithm iteratively shifts each observation towards the mode
of its neighborhood, defined using a kernel
with bandwidth h. The procedure continues until the shift distance is smaller
than a convergence threshold controlled by derr.
The distance between functional data is computed using the distance function metric,
which defaults to the L2 distance provided by metric.lp
from the fda.usc package. The bandwidth h controls the size of the neighborhood c
onsidered for the shift.
See also
See metric.lp for distance calculations.
Examples
if (FALSE) { # \dontrun{
set.seed(8:1)
t <- seq(0, 2 * pi, length.out = 101)
res <- rprocKclust(t, n = c(40, 40), process = c("cos_sin", "sin"),
c = c(-1, 2), k = c(NA, NA), s = c(0.3, 0.3))
# Run mean shift clustering with automatic bandwidth selection
result <- fmeanshift(res$X)
# Display cluster assignments and centers
table(result$cluster,res$groups)
plot(result$centers)
plot(res$X, col = result$cluster, main = "functional meanshift")
} # }