Performs hierarchical clustering on functional data using a specified clustering method.
The distance between functional observations is calculated using distance measures
from the fda.usc
package.
Arguments
- fdataobj
An object of class
fdata
representing the functional data to be clustered. Each row corresponds to a functional observation.- method
A character string specifying the agglomeration method to be used. Possible values are
"ward.D2"
,"single"
,"complete"
,"average"
,"mcquitty"
,"median"
, or"centroid"
. Defaults to"ward.D2"
.
Value
An object of class hclust
, which describes the tree produced by the hierarchical clustering process.
The object has the following components:
- merge
A numeric matrix describing the merge history.
- height
The height at which the mergers occurred.
- order
A vector giving the order of objects.
- labels
The labels of the objects being clustered.
- call
The call which produced the result.
- method
The agglomeration method used.
Details
The fhclust
function applies hierarchical clustering to functional data,
using distances calculated via the fda.usc::metric.lp
function.
The method for hierarchical clustering can be any of the agglomeration methods available
in hclust
.
This function is useful for clustering functional data such as time series, curves,
and other functional representations. The function returns an object of class
hclust
, which can be plotted and interpreted as a dendrogram.
Examples
if (FALSE) { # \dontrun{
t <- seq(0, 2 * pi, length.out = 101)
res <- rprocKclust(t, n = c(30, 50, 40), process = c("cos_sin", "sin", "cos"),
c = c(-1, 1, 1), k = c(NA, NA, NA), s = c(0.2, 0.3, 0.1))
# Perform hierarchical clustering using the default method (ward.D2)
result <- fhclust(res$X, method = "ward.D2")
# Plot the dendrogram
plot(result, main = "Dendrogram of Functional Data (Ward's Method)")
# Cut the dendrogram into clusters
groups <- cutree(result, k = 3)
print(table(res$groups,groups))
} # }