Fuzzy c-medoids clustering on tensor-product spline coefficients
cluster.coefs.Rd
cluster.coefs()
is used to apply a fuzzy c-medoids clustering algorithm to
the tensor-product spline coefficients that are output from the TPSfit
function.
Arguments
- TPSdata
Output from the TPSfit function.
- k
An integer value indicating the number of clusters.
- m
A numeric value called the 'fuzziness parameter.' Must be greater than 1, with a default of 1.2.
- noise
A logical expression indicating whether a noise cluster for outliers is to be included.
- seed
An optional numeric value for the seed, as the clustering algorithm uses random start values.
- ...
Additional optional values employed by
fclust
, includingRS
, the number of random starts, anddelta
, the distance for outliers.
Value
An object of class 'FKM.TPS
' containing the following components:
FKM_TPS
An object output by thefclust
algorithm.U
A dataframe containing the degrees of cluster membership for each subject.Umax
A vector containing the modal cluster assignment for each subject.FKM_TPS_U
A data frame containing subjects with subject ID, degrees of cluster membership, and modal class assignment.FKM_indices
A vector containing the values for six cluster validity indices. Seefclust::Fclust.index()
wide_data
A data frame with the values that were clustered on in the clustering algorithm plus subject IDs.TPSdata
TheTPSfit
object that was input into the function.noise
Logical value that was used to determine whether a noise cluster is included.k
The number of clusters.m
The fuzziness parameter.IDmatch
A data frame matching the original subject ID with new consecutive ID values.
Details
cluster.coefs()
employs package fclust
to apply a fuzzy c-medoids
clustering algorithm to the tensor-product spline coefficients that are
output from the TPSfit
function. The user has options of including a noise
cluster.
See also
cluster.fitted()
is an alternative method that clusters fitted spline values rather than spline coefficients.The
fclust
R package: https://cran.r-project.org/web/packages/fclust/index.htmlFuzzy k-medoids function:
fclust::FKM.med()
Fuzzy k-medoids function with noise cluster:
fclust::FKM.med.noise()
Examples
library(dplyr); library(tidyr); library(fclust)
#>
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#>
#> filter, lag
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, setequal, union
#' data(TS.sim)
fitsplines <- TPSfit(TS.sim, vars=c("Var1", "Var2", "Var3"), time="Time",
ID="SubjectID", knots_time=c(0, 91, 182, 273, 365), n_fit_times=10)
clusters2 <- cluster.coefs(fitsplines, k=3, m=1.3, seed=12345, RS=5, noise=TRUE)
summary(clusters2)
#> cluster.coefs(TPSdata = fitsplines, k = 3, m = 1.3, noise = TRUE,
#> seed = 12345, RS = 5)
#>
#> 150 subjects clustered into 3 clusters + noise cluster using m = 1.3
#> Clusters based on tensor-product splines coefficients
#>
#> Cluster summary:
#> Cl.size Min.degree Max.degree Mean.degree
#> Clus1 30 0.326 1.000 0.487
#> Clus2 49 0.354 1.000 0.921
#> Clus3 43 0.349 1.000 0.675
#> Noise 28 0.311 0.999 0.576
#>
#> Component 'FKM_TPS' contains the fuzzy clustering details from package 'fclust'.
#> Components of 'FKM_TPS':
#> [1] "U" "H" "F" "clus" "medoid" "value"
#> [7] "criterion" "iter" "k" "m" "ent" "b"
#> [13] "vp" "delta" "stand" "Xca" "X" "D"
#> [19] "call"
#>
#> Cluster validity indices:
#> PC PE MPC SIL SIL.F XB
#> 0.5338480 0.5881223 0.3007721 0.1190551 0.1316716 2.3993223
#>
#> Output dataset 'FKM_TPS_U' contains degree of cluster membership and modal
#> cluster assignment for each object.
#> Head of dataset 'FKM_TPS_U':
#> Id2 SubjectID Clus1 Clus2 Clus3 Noise ClusModal
#> 1 1 17 0.0001836595 0.9994971 0.0003074245 1.177236e-05 2
#> 2 2 19 0.4575291735 0.1261526 0.2864494603 1.298688e-01 1
#> 3 3 34 0.0020179751 0.9953520 0.0025581026 7.187532e-05 2
#> 4 4 52 0.0016033172 0.9964037 0.0018971158 9.585506e-05 2
#> 5 5 55 0.1687127692 0.2410988 0.2030380462 3.871503e-01 0
#> 6 6 83 0.1446869270 0.2082775 0.1342187362 5.128169e-01 0
#>