Fuzzy c-medoids clustering on fitted values of splines
cluster.fitted.Rd
cluster.fitted()
is used to apply a fuzzy c-medoids clustering algorithm to
the fitted values that are output from the TPSfit()
function.
Usage
cluster.fitted(
TPSdata,
center = TRUE,
addslopes = TRUE,
k,
m = 1.2,
noise = TRUE,
seed,
...
)
Arguments
- TPSdata
Output from the
TPSfit()
function.- center
A logical expression indicating that trajectories are to be centered on individual means.
- addslopes
A logical expression indicating that clustering will be conducted on the slopes between fitted time-points in addition to the cross-sectional values at each point.
- 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, including
RS
, 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
The 'TPSfit
' object that was input into the function.center
Logical value that was used to determine whether to center on individual trajectories.noise
Logical value that was used to determine whether a noise cluster is included.k
The number of clusters.m
The fuzziness parameter.addslopes
Logical value that was used to determine whether to include the slopes between fitted time-points.IDmatch
A data frame matching the original subject ID with new consecutive ID values.
Details
cluster.fitted()
employs package fclust to apply the fuzzy c-medoids
clustering algorithm to the fitted tensor-product spline values that are
output from the TPSfit()
function. The user has options of including a noise
cluster and centering trajectories on the individual means. The addslopes
option will cluster on the slopes between fitted time-points in addition to
cross-sectional fitting at those points.
See also
cluster.coefs()
is an alternative method that clusters on spline coefficients rather than fitted values.The fclust R package: https://CRAN.R-project.org/package=fclust
Fuzzy k-medoids function:
fclust::FKM.med()
Fuzzy k-medoids function with noise cluster:
fclust::FKM.med.noise()
Examples
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)
clusters1 <- cluster.fitted(fitsplines, k=3, m=1.3, seed=12345, RS=5, noise=TRUE)
summary(clusters1)
#> cluster.fitted(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 fitted values at times 0 40.44444 80.88889 121.3333 161.7778 202.2222 242.6667 283.1111 323.5556 364
#> and slopes between points
#>
#> Cluster summary:
#> Cl.size Min.degree Max.degree Mean.degree
#> Clus1 47 0.764 1 0.988
#> Clus2 46 0.872 1 0.989
#> Clus3 49 0.698 1 0.990
#> Noise 8 0.957 1 0.990
#>
#> 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.92767342 0.03821568 0.89151013 0.35189879 0.37201800 0.22314197
#>
#> 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 5.172103e-07 2.007963e-05 0.9999782952 1.107976e-06 3
#> 2 2 19 9.991481e-01 2.902820e-04 0.0002348860 3.266833e-04 1
#> 3 3 34 7.820025e-08 6.215939e-06 0.9999935927 1.131528e-07 3
#> 4 4 52 2.556221e-07 1.533165e-05 0.9999839290 4.836864e-07 3
#> 5 5 55 9.984985e-01 5.331182e-04 0.0003056236 6.627689e-04 1
#> 6 6 83 9.565796e-01 1.081446e-02 0.0055381485 2.706777e-02 1
#>