Learn R Programming

latrend (version 1.6.2)

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

354

Version

1.6.2

License

GPL (>= 2)

Issues

Pull Requests

Stars

Forks

Maintainer

Niek Den Teuling

Last Published

July 4th, 2025

Functions in latrend (1.6.2)

createTestDataFold

Create the test fold data for validation
clusterNames

Get the cluster names
.trajSubset

Select trajectories
clusterProportions

Proportional size of each cluster
.guessResponseVariable

Guess the response variable
confusionMatrix

Compute the posterior confusion matrix
converged

Check model convergence
fitted.lcModel

Extract lcModel fitted values
fittedTrajectories

Extract the fitted trajectories
compose

lcMethod estimation step: compose an lcMethod object
generateLongData

Generate longitudinal test data
defineExternalMetric

Define an external metric for lcModels
createTrainDataFolds

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

lcMethod estimation step: logic for fitting the method to the processed data
getArgumentDefaults

Default argument values for the given method specification
externalMetric

Compute external model metric(s)
coef.lcModel

Extract lcModel coefficients
getExternalMetricNames

Get the names of the available external metrics
getInternalMetricDefinition

Get the internal metric definition
createTestDataFolds

Create all k test folds from the training data
estimationTime

Estimation time
df.residual.lcModel

Extract the residual degrees of freedom from a lcModel
idVariable

Extract the trajectory identifier variable
ids

Get the trajectory ids on which the model was fitted
.defineInternalDistanceMetrics

Define the distance metrics for multiple types at once
getCitation

Get citation info
interface-mixtools

mixtools interface
defineInternalMetric

Define an internal metric for lcModels
formula.lcMethod

Extract formula
formula.lcModel

Extract the formula of a lcModel
deviance.lcModel

lcModel deviance
clusterTrajectories,lcModelPartition-method

function interface
getArgumentExclusions

Arguments to be excluded from the specification
latrend-is

Check if object is of Class
evaluate.lcMethod

Substitute the call arguments for their evaluated values
getLcMethod

Get the method specification
latrend

Cluster longitudinal data using the specified method
latrendBatch

Cluster longitudinal data for a list of method specifications
interface-mixtvem

mixtvem interface
interface-akmedoids

akmedoids interface
isArgDefined

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

crimCV interface
getCall.lcModel

Get the model call
getInternalMetricNames

Get the names of the available internal metrics
getLabel

Object label
latrend-generics

Generics used by latrend for different classes
latrend-estimation

Overview of lcMethod estimation functions
getName

Object name
interface-featureBased

featureBased interface
lcMatrixMethod-class

lcMatrixMethod
interface-dtwclust

dtwclust interface
interface-flexmix

flexmix interface
getExternalMetricDefinition

Get the external metric definition
lcApproxModel-class

lcApproxModel class
lcMethodLMKM

Two-step clustering through linear regression modeling and k-means
lcMethod-class

lcMethod class
lcMethodKML

Specify a longitudinal k-means (KML) method
getArgumentDefaults,lcMethodLcmmGMM-method

lcmm interface
lcMethod-estimation

Longitudinal cluster method (lcMethod) estimation procedure
latrend-parallel

Parallel computation using latrend
interface-mclust

mclust interface
lcMethodAkmedoids

Specify AKMedoids method
lcMethodFunction

Specify a custom method based on a function
latrend-package

latrend: A Framework for Clustering Longitudinal Data
lcMethodLcmmGBTM

Specify GBTM method
latrendRep

Cluster longitudinal data repeatedly
lcMethodFlexmixGBTM

Group-based trajectory modeling using flexmix
lcMethodGCKM

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

Artificial longitudinal dataset comprising three classes
lcFitMethods

Method fit modifiers
lcMethodDtwclust

Specify time series clustering via dtwclust
interface-metaMethods

lcMetaMethod abstract class
lcMethodRandom

Specify a random-partitioning method
lcMethodCrimCV

Specify a zero-inflated repeated-measures GBTM method
lcMethodMixtoolsNPRM

Specify non-parametric estimation for independent repeated measures
[[,lcMethod-method

Retrieve and evaluate a lcMethod argument by name
interface-mixAK

mixAK interface
latrend-methods

Supported methods for longitudinal clustering
latrend-metrics

Metrics
lcMethodLcmmGMM

Specify GMM method using lcmm
logLik.lcModel

Extract the log-likelihood of a lcModel
lcModel-class

lcModel class
metric

Compute internal model metric(s)
lcModel-data-filters

Data filters for lcModel
lcMethodMixAK_GLMM

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

Longitudinal latent profile analysis
lcMethodFunFEM

Specify a FunFEM method
latrendBoot

Cluster longitudinal data using bootstrapping
latrendCV

Cluster longitudinal data over k folds
lcMethodStratify

Specify a stratification method
min.lcModels

Select the lcModel with the lowest metric value
lcModelPartition

Create a lcModel with pre-defined partitioning
lcMethods

Generate a list of lcMethod objects
lcModel-make

Cluster-handling functions for lcModel implementations.
plotFittedTrajectories

Plot the fitted trajectories
plotMetric

Plot one or more internal metrics for all lcModels
lcModel

Longitudinal cluster result (lcModel)
predictForCluster

Predict trajectories conditional on cluster membership
strip

Reduce the memory footprint of an object for serialization
predictPostprob

Posterior probability for new data
sigma.lcModel

Extract residual standard deviation from a lcModel
lcModelWeightedPartition

Create a lcModel with pre-defined weighted partitioning
plot-lcModel-method

Plot a lcModel
plotTrajectories

Plot the data trajectories
nIds

Number of trajectories
postFit

lcMethod estimation step: logic for post-processing the fitted lcModel
names,lcMethod-method

lcMethod argument names
nobs.lcModel

Number of observations used for the lcModel fit
qqPlot

Quantile-quantile plot
print.lcModels

Print lcModels list concisely
validate

lcMethod estimation step: method argument validation logic
weighted.meanNA

Weighted arithmetic mean ignoring NAs
initialize,lcMethod-method

lcMethod initialization
match.call.all

Argument matching with defaults and parent ellipsis expansion
model.data

Extract the model training data
model.data.lcModel

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

Extract lcModel residuals
model.frame.lcModel

Extract model training data
subset.lcModels

Subsetting a lcModels list based on method arguments
tsframe

Convert a multiple time series matrix to a data.frame
summary.lcModel

Summarize a lcModel
lcMethodFeature

Feature-based clustering
lcMethodMixTVEM

Specify a MixTVEM
interface-funFEM

funFEM interface
postprobFromAssignments

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

Number of clusters
latrend-approaches

High-level approaches to longitudinal clustering
latrend-data

Longitudinal dataset representation
lcMethodFlexmix

Method interface to flexmix()
postprob

Posterior probability per fitted trajectory
predict.lcModel

lcModel predictions
trajectoryAssignments

Get the cluster membership of each trajectory
time.lcModel

Sampling times of a lcModel
preFit

lcMethod estimation step: method preparation logic
postProbFromObs

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

kml interface
responseVariable

Extract response variable
lcMethodMixtoolsGMM

Specify mixed mixture regression model using mixtools
lcModels-class

lcModels: a list of lcModel objects
trajectories

Get the trajectories
predictAssignments

Predict the cluster assignments for new trajectories
update.lcMethod

Update a method specification
update.lcModel

Update a lcModel
timeVariable

Extract the time variable
transformPredict

Helper function for custom lcModel classes implementing predict.lcModel()
transformFitted

Helper function for custom lcModel classes implementing fitted.lcModel()
plot-lcModels-method

Grid plot for a list of models
lcModels

Construct a list of lcModel objects
meanNA

Mean ignoring NAs
plotClusterTrajectories

Plot cluster trajectories
max.lcModels

Select the lcModel with the highest metric value
tsmatrix

Convert a longitudinal data.frame to a matrix
which.weight

Sample an index of a vector weighted by the elements
prepareData

lcMethod estimation step: logic for preparing the training data
print.lcMethod

Print the arguments of an lcMethod object
test.latrend

Test the implementation of an lcMethod and associated lcModel subclasses
test

Test a condition
as.data.frame.lcMethods

Convert a list of lcMethod objects to a data.frame
as.lcModels

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

Biweekly Mean PAP Therapy Adherence of OSA Patients over 1 Year
as.lcMethods

Convert a list of lcMethod objects to a lcMethods list
APPA

Average posterior probability of assignment (APPA)
as.data.frame.lcModels

Generate a data.frame containing the argument values per method per row
as.data.frame.lcMethod

Convert lcMethod arguments to a list of atomic types
OCC

Odds of correct classification (OCC)
as.list.lcMethod

Extract the method arguments as a list
clusterTrajectories

Extract cluster trajectories
clusterSizes

Number of trajectories per cluster
PAP.adh

Weekly Mean PAP Therapy Usage of OSA Patients in the First 3 Months
clusterNames<-

Update the cluster names
latrend-assert

latrend-specific assertions