Learn R Programming

latrend (version 1.6.3)

A Framework for Clustering Longitudinal Data

Description

A framework for clustering longitudinal datasets in a standardized way. The package provides an interface to existing R packages for clustering longitudinal univariate trajectories, facilitating reproducible and transparent analyses. Additionally, standard tools are provided to support cluster analyses, including repeated estimation, model validation, and model assessment. The interface enables users to compare results between methods, and to implement and evaluate new methods with ease. The 'akmedoids' package is available from .

Copy Link

Version

Install

install.packages('latrend')

Monthly Downloads

342

Version

1.6.3

License

GPL (>= 2)

Issues

Pull Requests

Stars

Forks

Maintainer

Niek Den Teuling

Last Published

February 13th, 2026

Functions in latrend (1.6.3)

clusterSizes

Number of trajectories per cluster
converged

Check model convergence
clusterNames

Get the cluster names
latrend-assert

latrend-specific assertions
clusterTrajectories

Extract cluster trajectories
confusionMatrix

Compute the posterior confusion matrix
coef.lcModel

Extract lcModel coefficients
compose

lcMethod estimation step: compose an lcMethod object
clusterProportions

Proportional size of each cluster
clusterNames<-

Update the cluster names
createTestDataFold

Create the test fold data for validation
createTestDataFolds

Create all k test folds from the training data
.defineInternalDistanceMetrics

Define the distance metrics for multiple types at once
deviance.lcModel

lcModel deviance
defineInternalMetric

Define an internal metric for lcModels
defineExternalMetric

Define an external metric for lcModels
df.residual.lcModel

Extract the residual degrees of freedom from a lcModel
createTrainDataFolds

Create the training data for each of the k models in k-fold cross validation evaluation
.trajSubset

Select trajectories
.guessResponseVariable

Guess the response variable
estimationTime

Estimation time
fittedTrajectories

Extract the fitted trajectories
formula.lcMethod

Extract formula
formula.lcModel

Extract the formula of a lcModel
generateLongData

Generate longitudinal test data
evaluate.lcMethod

Substitute the call arguments for their evaluated values
externalMetric

Compute external model metric(s)
fitted.lcModel

Extract lcModel fitted values
getArgumentDefaults

Default argument values for the given method specification
fit

lcMethod estimation step: logic for fitting the method to the processed data
getCall.lcModel

Get the model call
getLcMethod

Get the method specification
getExternalMetricNames

Get the names of the available external metrics
getExternalMetricDefinition

Get the external metric definition
getInternalMetricDefinition

Get the internal metric definition
getCitation

Get citation info
getName

Object name
getArgumentExclusions

Arguments to be excluded from the specification
getLabel

Object label
getInternalMetricNames

Get the names of the available internal metrics
interface-akmedoids

akmedoids interface
interface-featureBased

featureBased interface
clusterTrajectories,lcModelPartition-method

function interface
ids

Get the trajectory ids on which the model was fitted
idVariable

Extract the trajectory identifier variable
[[,lcMethod-method

Retrieve and evaluate a lcMethod argument by name
interface-crimCV

crimCV interface
interface-dtwclust

dtwclust interface
initialize,lcMethod-method

lcMethod initialization
interface-flexmix

flexmix interface
interface-mixtvem

mixtvem interface
interface-metaMethods

lcMetaMethod abstract class
getArgumentDefaults,lcMethodLcmmGMM-method

lcmm interface
interface-mixtools

mixtools interface
interface-funFEM

funFEM interface
latrend-is

Check if object is of Class
interface-kml

kml interface
isArgDefined

Check whether the argument of a lcMethod has a defined value.
interface-mixAK

mixAK interface
interface-mclust

mclust interface
latrend-estimation

Overview of lcMethod estimation functions
latrend

Cluster longitudinal data using the specified method
latrend-generics

Generics used by latrend for different classes
latrend-parallel

Parallel computation using latrend
latrend-data

Longitudinal dataset representation
latrend-package

latrend: A Framework for Clustering Longitudinal Data
latrend-approaches

High-level approaches to longitudinal clustering
latrendBatch

Cluster longitudinal data for a list of method specifications
latrend-methods

Supported methods for longitudinal clustering
latrend-metrics

Metrics
latrendData

Artificial longitudinal dataset comprising three classes
lcMethod-class

lcMethod class
lcMethod-estimation

Longitudinal cluster method (lcMethod) estimation procedure
lcMethodAkmedoids

Specify AKMedoids method
lcApproxModel-class

lcApproxModel class
latrendBoot

Cluster longitudinal data using bootstrapping
latrendRep

Cluster longitudinal data repeatedly
lcFitMethods

Method fit modifiers
latrendCV

Cluster longitudinal data over k folds
lcMatrixMethod-class

lcMatrixMethod
lcMethodKML

Specify a longitudinal k-means (KML) method
lcMethodGCKM

Two-step clustering through latent growth curve modeling and k-means
lcMethodFunction

Specify a custom method based on a function
lcMethodLMKM

Two-step clustering through linear regression modeling and k-means
lcMethodFlexmixGBTM

Group-based trajectory modeling using flexmix
lcMethodCrimCV

Specify a zero-inflated repeated-measures GBTM method
lcMethodDtwclust

Specify time series clustering via dtwclust
lcMethodFlexmix

Method interface to flexmix()
lcMethodFunFEM

Specify a FunFEM method
lcMethodFeature

Feature-based clustering
lcMethodMixtoolsGMM

Specify mixed mixture regression model using mixtools
lcMethodMixAK_GLMM

Specify a GLMM iwht a normal mixture in the random effects
lcMethodStratify

Specify a stratification method
lcMethodRandom

Specify a random-partitioning method
lcMethodMclustLLPA

Longitudinal latent profile analysis
lcMethods

Generate a list of lcMethod objects
lcMethodMixtoolsNPRM

Specify non-parametric estimation for independent repeated measures
lcMethodLcmmGBTM

Specify GBTM method
lcMethodLcmmGMM

Specify GMM method using lcmm
lcMethodMixTVEM

Specify a MixTVEM
lcModels

Construct a list of lcModel objects
lcModelWeightedPartition

Create a lcModel with pre-defined weighted partitioning
lcModel-make

Cluster-handling functions for lcModel implementations.
lcModel-class

lcModel class
logLik.lcModel

Extract the log-likelihood of a lcModel
lcModels-class

lcModels: a list of lcModel objects
lcModelPartition

Create a lcModel with pre-defined partitioning
lcModel

Longitudinal cluster result (lcModel)
lcModel-data-filters

Data filters for lcModel
match.call.all

Argument matching with defaults and parent ellipsis expansion
model.data.lcModel

Extract the model data that was used for fitting
model.data

Extract the model training data
nIds

Number of trajectories
max.lcModels

Select the lcModel with the highest metric value
min.lcModels

Select the lcModel with the lowest metric value
names,lcMethod-method

lcMethod argument names
nClusters

Number of clusters
model.frame.lcModel

Extract model training data
metric

Compute internal model metric(s)
meanNA

Mean ignoring NAs
plotMetric

Plot one or more internal metrics for all lcModels
plotClusterTrajectories

Plot cluster trajectories
plot-lcModels-method

Grid plot for a list of models
plotFittedTrajectories

Plot the fitted trajectories
plotTrajectories

Plot the data trajectories
postFit

lcMethod estimation step: logic for post-processing the fitted lcModel
postProbFromObs

Compute the id-specific postprob matrix from a given observation-level postprob matrix
postprob

Posterior probability per fitted trajectory
nobs.lcModel

Number of observations used for the lcModel fit
plot-lcModel-method

Plot a lcModel
postprobFromAssignments

Create a posterior probability matrix from a vector of cluster assignments.
prepareData

lcMethod estimation step: logic for preparing the training data
predict.lcModel

lcModel predictions
predictForCluster

Predict trajectories conditional on cluster membership
qqPlot

Quantile-quantile plot
print.lcMethod

Print the arguments of an lcMethod object
print.lcModels

Print lcModels list concisely
predictAssignments

Predict the cluster assignments for new trajectories
preFit

lcMethod estimation step: method preparation logic
predictPostprob

Posterior probability for new data
summary.lcModel

Summarize a lcModel
subset.lcModels

Subsetting a lcModels list based on method arguments
time.lcModel

Sampling times of a lcModel
sigma.lcModel

Extract residual standard deviation from a lcModel
residuals.lcModel

Extract lcModel residuals
strip

Reduce the memory footprint of an object for serialization
timeVariable

Extract the time variable
responseVariable

Extract response variable
test.latrend

Test the implementation of an lcMethod and associated lcModel subclasses
test

Test a condition
update.lcMethod

Update a method specification
tsframe

Convert a multiple time series matrix to a data.frame
trajectoryAssignments

Get the cluster membership of each trajectory
tsmatrix

Convert a longitudinal data.frame to a matrix
trajectories

Get the trajectories
validate

lcMethod estimation step: method argument validation logic
transformPredict

Helper function for custom lcModel classes implementing predict.lcModel()
weighted.meanNA

Weighted arithmetic mean ignoring NAs
update.lcModel

Update a lcModel
transformFitted

Helper function for custom lcModel classes implementing fitted.lcModel()
which.weight

Sample an index of a vector weighted by the elements
as.data.frame.lcModels

Generate a data.frame containing the argument values per method per row
PAP.adh

Weekly Mean PAP Therapy Usage of OSA Patients in the First 3 Months
OCC

Odds of correct classification (OCC)
as.data.frame.lcMethods

Convert a list of lcMethod objects to a data.frame
APPA

Average posterior probability of assignment (APPA)
as.lcMethods

Convert a list of lcMethod objects to a lcMethods list
as.list.lcMethod

Extract the method arguments as a list
as.data.frame.lcMethod

Convert lcMethod arguments to a list of atomic types
as.lcModels

Convert a list of lcModels to a lcModels list
PAP.adh1y

Biweekly Mean PAP Therapy Adherence of OSA Patients over 1 Year