The fdacluster package
provides implementations of the fdakmeans()
for the fdahclust()
for HAC and
fdadbscan()
for DBSCAN. The methods handle multivariate codomains.
You can install the official version from CRAN via:
install.packages("fdacluster")
or you can opt to install the development version from GitHub with:
# install.packages("remotes")
remotes::install_github("astamm/fdacluster")
Let us consider the following simulated example of
Looking at the data set, it seems that we shall expect
We can perform
out1 <- fdakmeans(
simulated30$x,
simulated30$y,
seeds = c(1, 21),
n_clusters = 2,
centroid_type = "mean",
warping_class = "affine",
metric = "normalized_l2",
cluster_on_phase = FALSE
)
All of
fdakmeans()
,
fdahclust()
and
fdadbscan()
functions returns an object of class
caps
(for
Clustering with Amplitude and Phase Separation) for
which S3
specialized methods of
ggplot2::autoplot()
and
graphics::plot()
have been implemented. Therefore, we can visualize the results simply
with:
plot(out1, type = "amplitude")
plot(out1, type = "phase")
We can perform cluster_on_phase
argument to TRUE
:
out2 <- fdakmeans(
simulated30$x,
simulated30$y,
seeds = c(1, 11, 21),
n_clusters = 3,
centroid_type = "mean",
warping_class = "affine",
metric = "normalized_l2",
cluster_on_phase = TRUE
)
We can inspect the result:
plot(out2, type = "amplitude")
plot(out2, type = "phase")
We can perform similar analyses using HAC or DBSCAN instead of
compare_caps()
and
plot.mcaps()
.