trajClusters: Classify the Longitudinal Data Based on the Measures.

trajClustersR Documentation

Classify the Longitudinal Data Based on the Measures.

Description

Classifies the trajectories by applying a nonparametric clustering algorithm to the measures computed by trajMeasures().

Usage

trajClusters(
  Measures,
  select = NULL,
  fuzzy = FALSE,
  nclusters = NULL,
  subset.n = NULL,
  nstart = 50
)

## S3 method for class 'trajClusters'
print(x, ...)

## S3 method for class 'trajClusters'
summary(object, top_p = 3, ...)

Arguments

Measures

object of class trajMeasures as returned by the function trajMeasures().

select

an optional vector of positive integers corresponding to the measures to use in the clustering. Defaults to NULL, which uses all the measures contained in Measures.

fuzzy

logical. If FALSE, each trajectory is assigned to a unique group. If TRUE, each trajectory is assigned a "degree of membership" to each group. Defaults to FALSE.

nclusters

The desired number of clusters. If NULL, clustering is carried out for every number of clusters between 2 and (up to) 8 and the "best" number of clusters is used, as judged by the combination of three internal cluster validity indices. See section 'Value' for more details. Defaults to NULL.

subset.n

A positive numerical integer smaller than the number of trajectories. If nclusters is NULL, subset is the number of trajectories, randomly sampled from the complete data set, that will be used to determine the optimal number of clusters in the interest of speeding up the process.

nstart

The number of random starts. Defaults to 50.

x

object of class trajClusters.

...

further arguments passed to or from other methods.

object

object of class trajClusters.

top_p

The top_p most discriminating measures for each cluster to be reported in the summary.

Details

The spectral clustering algorithm presented in Meila (2005) is implemented in which the similarity matrix S is built from a binary K nearest neighbors similarity function (S=(W+W^T)/2, where W_{ij}=1 if data point j is among the nearest points to data point i and W_{ij}=0 otherwise).

When nclusters = NULL, the function evaluates candidate clusterings with number of clusters k ranging from 2 to 8 using three internal validity indices: C-index, Calinski-Harabasz and Wemmert-Gançarski. These indices are normalized so that the highest value is 1 and the lowest is 0, and so that a high value is synonymous with high validity. The optimal number of clusters is determined according to a ranked voting system in which each index contributes a fractional vote according to its ranking of the candidate solutions. Specifically, each index casts a vote worth 1 in favor of k if it takes its greatest value when the number of groups is k, worth 5/6 if it takes its second greatest value when the number of groups is k, and so on down to a vote worth 0 if the index takes its smallest value when the number of groups is k. The favorability of k is the sum of the 3 votes.

Value

An object of class trajClusters; a list containing the result of the clustering, as well as a curated form of the arguments.

References

Meila, M., Spectral Clustering. Handbook of Cluster Analysis, Chapter 7, Chapman and Hall/CRC, 2005.

Examples

## Not run: 
data("trajdata")
trajdata.noGrp <- trajdata[, -which(colnames(trajdata) == "Group")] # remove the Group column

m = trajMeasures(trajdata.noGrp, ID = TRUE, measures = 1:20)

s2.3 <- trajClusters(m, nclusters = 3)
plot(s2.3)

s2.4 <- trajClusters(m, nclusters = 4)
plot(s2.4)

s2.5 <- trajClusters(m, nclusters = 5)
plot(s2.5)

groups <- trajClusters(m, nclusters = 4)$partition

## End(Not run)



traj documentation built on Sept. 9, 2026, 1:07 a.m.