latrend-package {latrend}R Documentation

latrend: 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 https://github.com/MAnalytics/akmedoids.

Features

The supported types of longitudinal datasets are described here.

Getting started

The latrendData dataset is included with the package and is used in all examples. The plotTrajectories() function can be used to visualize any longitudinal dataset, given the id and time are specified.

data(latrendData)
head(latrendData)
options(latrend.id = "Id", latrend.time = "Time")
plotTrajectories(latrendData, response = "Y")

Discovering longitudinal clusters using the package involves the specification of the longitudinal cluster method that should be used.

kmlMethod <- lcMethodKML("Y", nClusters = 3)
kmlMethod

The specified method is then estimated on the data using the generic estimation procedure function latrend():

model <- latrend(kmlMethod, data = latrendData)

We can then investigate the fitted model using

summary(model)
plot(model)
metric(model, c("WMAE", "BIC"))
qqPlot(model)

Create derivative method specifications for 1 to 5 clusters using the lcMethods() function. A series of methods can be estimated using latrendBatch().

kmlMethods <- lcMethods(kmlMethod, nClusters = 1:5)
models <- latrendBatch(kmlMethods, data = latrendData)

Determine the number of clusters through one or more internal cluser metrics. This can be done visually using the plotMetric() function.

plotMetric(models, c("WMAE", "BIC"))

Vignettes

Further step-by-step instructions on how to use the package are described in the vignettes.

Useful pages

Data requirements and datasets: latrend-data latrendData PAP.adh

High-level method recommendations and supported methods: latrend-approaches latrend-methods

Method specification: lcMethod lcMethods

Method estimation: latrend latrendRep latrendBatch latrendBoot latrendCV latrend-parallel Steps performed during estimation

Model functions: lcModel clusterTrajectories plotClusterTrajectories postprob trajectoryAssignments predictPostprob predictAssignments predict.lcModel predictForCluster fitted.lcModel fittedTrajectories

Author(s)

Maintainer: Niek Den Teuling niek.den.teuling@philips.com (ORCID)

Other contributors:

See Also

Useful links:


[Package latrend version 1.6.0 Index]