Package: latrend 1.6.1

Niek Den Teuling

latrend: A Framework for Clustering Longitudinal Data

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>.

Authors:Niek Den Teuling [aut, cre], Steffen Pauws [ctb], Edwin van den Heuvel [ctb], Koninklijke Philips N.V. [cph]

latrend_1.6.1.tar.gz
latrend_1.6.1.zip(r-4.5)latrend_1.6.1.zip(r-4.4)latrend_1.6.1.zip(r-4.3)
latrend_1.6.1.tgz(r-4.4-any)latrend_1.6.1.tgz(r-4.3-any)
latrend_1.6.1.tar.gz(r-4.5-noble)latrend_1.6.1.tar.gz(r-4.4-noble)
latrend_1.6.1.tgz(r-4.4-emscripten)latrend_1.6.1.tgz(r-4.3-emscripten)
latrend.pdf |latrend.html
latrend/json (API)

# Install 'latrend' in R:
install.packages('latrend', repos = c('https://philips-software.r-universe.dev', 'https://cloud.r-project.org'))

Peer review:

Bug tracker:https://github.com/philips-software/latrend/issues

Datasets:
  • PAP.adh - Weekly Mean PAP Therapy Usage of OSA Patients in the First 3 Months
  • PAP.adh1y - Biweekly Mean PAP Therapy Adherence of OSA Patients over 1 Year
  • latrendData - Artificial longitudinal dataset comprising three classes

On CRAN:

cluster-analysisclustering-evaluationclustering-methodsdata-sciencelongitudinal-clusteringlongitudinal-datamixture-modelstime-series-analysis

7.02 score 28 stars 25 scripts 470 downloads 122 exports 38 dependencies

Last updated 8 days agofrom:4261628668. Checks:OK: 5 NOTE: 2. Indexed: yes.

TargetResultDate
Doc / VignettesOKNov 18 2024
R-4.5-winNOTENov 18 2024
R-4.5-linuxNOTENov 18 2024
R-4.4-winOKNov 18 2024
R-4.4-macOKNov 18 2024
R-4.3-winOKNov 18 2024
R-4.3-macOKNov 18 2024

Exports:APPAare_trajectories_equal_lengthare_trajectories_lengthas.lcMethodsas.lcModelsbootSampleclusterNamesclusterNames<-clusterProportionsclusterSizesclusterTrajectoriescomposeconfusionMatrixconvergedcreateTestDataFoldcreateTestDataFoldscreateTrainDataFoldsdefineExternalMetricdefineInternalMetricestimationTimeexternalMetricfitfittedTrajectoriesgenerateLongDatagetArgumentDefaultsgetArgumentExclusionsgetCitationgetExternalMetricDefinitiongetExternalMetricNamesgetInternalMetricDefinitiongetInternalMetricNamesgetLabelgetLcMethodgetNamegetShortNamehas_lcMethod_argshave_trajectories_noNAidsidVariableis_datais_valid_postprobis.lcMethodis.lcModelis.lcModelsisArgDefinedlatrendlatrendBatchlatrendBootlatrendCVlatrendReplcFitConvergedlcFitReplcFitRepMaxlcFitRepMinlcMethodAkmedoidslcMethodCrimCVlcMethodDtwclustlcMethodFeaturelcMethodFlexmixlcMethodFlexmixGBTMlcMethodFunctionlcMethodFunFEMlcMethodGCKMlcMethodKMLlcMethodLcmmGBTMlcMethodLcmmGMMlcMethodLMKMlcMethodMclustLLPAlcMethodMixAK_GLMMlcMethodMixtoolsGMMlcMethodMixtoolsNPRMlcMethodMixTVEMlcMethodRandomlcMethodslcMethodStratifylcModelPartitionlcModelslcModelWeightedPartitionmake.clusterIndicesmake.clusterNamesmake.clusterPropLabelsmake.clusterSizeLabelsmake.trajectoryAssignmentsmatch.call.allmeanNAmetricmodel.datanClustersnIdsno_empty_trajectoriesno_trajectories_allNAno_trajectories_duplicate_timeOCCplotplotClusterTrajectoriesplotFittedTrajectoriesplotMetricplotTrajectoriespostFitpostprobpostprobFromAssignmentspredictAssignmentspredictForClusterpredictPostprobpreFitprepareDataqqPlotresponseVariablestriptest.latrendtestFoldtimeVariabletrainFoldtrajectoriestrajectoryAssignmentstransformFittedtransformPredicttsframetsmatrixvalidateweighted.meanNAwhich.weight

Dependencies:assertthatbase64encbslibcachemclicodetoolsdata.tabledigestevaluatefastmapfontawesomeforeachfsgluehighrhtmltoolsiteratorsjquerylibjsonliteknitrlifecyclemagrittrmatrixStatsmemoisemimeR.methodsS3R.ooR.utilsR6rappdirsrbibutilsRdpackrlangrmarkdownsasstinytexxfunyaml

Conducting a simulation study

Rendered fromsimulation.Rmdusingknitr::rmarkdownon Nov 18 2024.

Last update: 2024-02-18
Started: 2021-11-02

Demonstration of latrend package

Rendered fromdemo.Rmdusingknitr::rmarkdownon Nov 18 2024.

Last update: 2024-02-18
Started: 2020-05-14

Implementing new methods

Rendered fromimplement.Rmdusingknitr::rmarkdownon Nov 18 2024.

Last update: 2024-02-18
Started: 2021-11-02

Readme and manuals

Help Manual

Help pageTopics
latrend: A Framework for Clustering Longitudinal Datalatrend-package
Retrieve and evaluate a lcMethod argument by name$,lcMethod-method [[,lcMethod-method
Average posterior probability of assignment (APPA)APPA
Convert lcMethod arguments to a list of atomic typesas.data.frame.lcMethod
Convert a list of lcMethod objects to a data.frameas.data.frame.lcMethods
Generate a data.frame containing the argument values per method per rowas.data.frame.lcModels
Convert a list of lcMethod objects to a lcMethods listas.lcMethods
Convert a list of lcModels to a lcModels listas.lcModels
Extract the method arguments as a listas.list.lcMethod
Get the cluster namesclusterNames
Update the cluster namesclusterNames<-
Proportional size of each clusterclusterProportions clusterProportions,lcModel-method
Number of trajectories per clusterclusterSizes
Extract cluster trajectoriesclusterTrajectories clusterTrajectories,lcModel-method
Extract lcModel coefficientscoef.lcModel
'lcMethod' estimation step: compose an lcMethod objectcompose compose,lcMethod-method
Compute the posterior confusion matrixconfusionMatrix
Check model convergenceconverged converged,lcModel-method
Create the test fold data for validationcreateTestDataFold
Create all k test folds from the training datacreateTestDataFolds
Create the training data for each of the k models in k-fold cross validation evaluationcreateTrainDataFolds
Define an external metric for lcModelsdefineExternalMetric
Define an internal metric for lcModelsdefineInternalMetric
lcModel deviancedeviance.lcModel
Extract the residual degrees of freedom from a lcModeldf.residual.lcModel
Estimation timeestimationTime estimationTime,lcModel-method estimationTime,lcModels-method estimationTime,list-method
Substitute the call arguments for their evaluated valuesevaluate.lcMethod
Compute external model metric(s)externalMetric externalMetric,lcModel,lcModel-method externalMetric,lcModels,character-method externalMetric,lcModels,lcModel-method externalMetric,lcModels,lcModels-method externalMetric,lcModels,missing-method externalMetric,list,lcModel-method
'lcMethod' estimation step: logic for fitting the method to the processed datafit fit,lcMethod-method
Extract lcModel fitted valuesfitted.lcModel
Extract the fitted trajectoriesfittedTrajectories fittedTrajectories,lcModel-method
Extract formulaformula.lcMethod
Extract the formula of a lcModelformula.lcModel
Generate longitudinal test datagenerateLongData
Default argument values for the given method specificationgetArgumentDefaults getArgumentDefaults,lcMethod-method
Arguments to be excluded from the specificationgetArgumentExclusions getArgumentExclusions,lcMethod-method
Get citation infogetCitation getCitation,lcMethod-method getCitation,lcModel-method
Get the external metric definitiongetExternalMetricDefinition
Get the names of the available external metricsgetExternalMetricNames
Get the internal metric definitiongetInternalMetricDefinition
Get the names of the available internal metricsgetInternalMetricNames
Object labelgetLabel getLabel,lcMethod-method getLabel,lcModel-method
Get the method specificationgetLcMethod getLcMethod,lcModel-method
Object namegetName getName,lcMethod-method getName,lcModel-method getName,NULL-method getShortName getShortName,lcMethod-method getShortName,lcModel-method getShortName,NULL-method
Get the trajectory ids on which the model was fittedids
Extract the trajectory identifier variableidVariable idVariable,ANY-method idVariable,lcMethod-method idVariable,lcModel-method
lcMethod initializationinitialize,lcMethod-method
lcMetaMethod abstract classcompose,lcMetaMethod-method fit,lcFitConverged-method fit,lcFitRep-method fit,lcMetaMethod-method getLcMethod,lcMetaMethod-method getName,lcMetaMethod-method getShortName,lcMetaMethod-method idVariable,lcMetaMethod-method interface-metaMethods lcMetaMethod-class postFit,lcMetaMethod-method preFit,lcMetaMethod-method prepareData,lcMetaMethod-method responseVariable,lcMetaMethod-method timeVariable,lcMetaMethod-method update.lcMetaMethod validate,lcFitConverged-method validate,lcFitRep-method validate,lcMetaMethod-method
Cluster longitudinal data using the specified methodlatrend
High-level approaches to longitudinal clusteringlatrend-approaches
Longitudinal dataset representationlatrend-data
Overview of *'lcMethod'* estimation functionslatrend-estimation
Generics used by latrend for different classeslatrend-generics
Supported methods for longitudinal clusteringlatrend-methods
Metricslatrend-metrics
Parallel computation using latrendlatrend-parallel
Cluster longitudinal data for a list of method specificationslatrendBatch
Cluster longitudinal data using bootstrappinglatrendBoot
Cluster longitudinal data over k foldslatrendCV
Artificial longitudinal dataset comprising three classeslatrendData
Cluster longitudinal data repeatedlylatrendRep
lcApproxModel classfitted.lcApproxModel lcApproxModel lcApproxModel-class predictForCluster,lcApproxModel-method
Method fit modifierslcFitConverged lcFitConverged-class lcFitMethods lcFitRep lcFitRep-class lcFitRepMax lcFitRepMin lcMetaMethods
lcMethod classlcMethod lcMethod-class
Longitudinal cluster method ('lcMethod') estimation procedurelatrend-procedure lcMethod-estimation lcMethod-steps
Specify AKMedoids methodlcMethodAkmedoids
Specify a zero-inflated repeated-measures GBTM methodlcMethodCrimCV
Specify time series clustering via dtwclustlcMethodDtwclust
Feature-based clusteringlcMethodFeature
Method interface to flexmix()lcMethodFlexmix
Group-based trajectory modeling using flexmixlcMethodFlexmixGBTM
Specify a custom method based on a functionlcMethodFunction
Specify a FunFEM methodlcMethodFunFEM
Two-step clustering through latent growth curve modeling and k-meanslcMethodGCKM
Specify a longitudinal k-means (KML) methodlcMethodKML
Specify GBTM methodlcMethodLcmmGBTM
Specify GMM method using lcmmlcMethodLcmmGMM
Two-step clustering through linear regression modeling and k-meanslcMethodLMKM
Longitudinal latent profile analysislcMethodMclustLLPA
Specify a GLMM iwht a normal mixture in the random effectslcMethodMixAK_GLMM
Specify mixed mixture regression model using mixtoolslcMethodMixtoolsGMM
Specify non-parametric estimation for independent repeated measureslcMethodMixtoolsNPRM
Specify a MixTVEMlcMethodMixTVEM
Specify a random-partitioning methodlcMethodRandom
Generate a list of lcMethod objectslcMethods
Specify a stratification methodlcMethodStratify
Longitudinal cluster result (*'lcModel'*)lcModel
'lcModel' classlcModel-class
Create a lcModel with pre-defined partitioninglcModelPartition
Construct a list of 'lcModel' objectslcModels
'lcModels': a list of 'lcModel' objectslcModels-class
Create a lcModel with pre-defined weighted partitioninglcModelWeightedPartition
Extract the log-likelihood of a lcModellogLik.lcModel
Select the lcModel with the highest metric valuemax.lcModels
Compute internal model metric(s)internalMetric metric metric,lcModel-method metric,lcModels-method metric,list-method
Select the lcModel with the lowest metric valuemin.lcModels
Extract the model data that was used for fittingmodel.data.lcModel
Extract model training datamodel.frame.lcModel
lcMethod argument nameslength,lcMethod-method names,lcMethod-method
Number of clustersnClusters nClusters,lcModel-method
Number of trajectoriesnIds
Number of observations used for the lcModel fitnobs.lcModel
Odds of correct classification (OCC)OCC
Weekly Mean PAP Therapy Usage of OSA Patients in the First 3 MonthsPAP.adh
Biweekly Mean PAP Therapy Adherence of OSA Patients over 1 YearPAP.adh1y
Plot a lcModelplot,lcModel,ANY-method plot,lcModel-method plot-lcModel-method
Grid plot for a list of modelsplot,lcModels,ANY-method plot,lcModels-method plot-lcModels-method
Plot cluster trajectoriesplotClusterTrajectories plotClusterTrajectories,data.frame-method plotClusterTrajectories,lcModel-method
Plot the fitted trajectoriesplotFittedTrajectories plotFittedTrajectories,lcModel-method
Plot one or more internal metrics for all lcModelsplotMetric
Plot the data trajectoriesplotTrajectories plotTrajectories,ANY-method plotTrajectories,data.frame-method plotTrajectories,lcModel-method
'lcMethod' estimation step: logic for post-processing the fitted lcModelpostFit postFit,lcMethod-method
Posterior probability per fitted trajectorypostprob postprob,lcModel-method
Create a posterior probability matrix from a vector of cluster assignments.postprobFromAssignments
lcModel predictionspredict.lcModel
Predict the cluster assignments for new trajectoriespredictAssignments predictAssignments,lcModel-method
Predict trajectories conditional on cluster membershippredictForCluster predictForCluster,lcModel-method
Posterior probability for new datapredictPostprob predictPostprob,lcModel-method
'lcMethod' estimation step: method preparation logicpreFit preFit,lcMethod-method
'lcMethod' estimation step: logic for preparing the training dataprepareData prepareData,lcMethod-method
Print the arguments of an lcMethod objectprint.lcMethod
Print lcModels list conciselyprint.lcModels
Quantile-quantile plotqqPlot
Extract lcModel residualsresiduals.lcModel
Extract response variableresponseVariable responseVariable,lcMethod-method responseVariable,lcModel-method
Extract residual standard deviation from a lcModelsigma.lcModel
Reduce the memory footprint of an object for serializationstrip strip,ANY-method strip,lcMethod-method strip,lcModel-method
Subsetting a lcModels list based on method argumentssubset.lcModels
Summarize a lcModelsummary.lcModel
Test the implementation of an lcMethod and associated lcModel subclassestest.latrend
Sampling times of a lcModeltime.lcModel
Extract the time variabletimeariable,ANY-method timeVariable timeVariable,ANY-method timeVariable,lcMethod-method timeVariable,lcModel-method
Get the trajectoriestrajectories trajectories,call-method trajectories,data.frame-method trajectories,lcModel-method trajectories,matrix-method
Get the cluster membership of each trajectorytrajectoryAssignments trajectoryAssignments,lcModel-method trajectoryAssignments,matrix-method
Helper function for custom lcModel classes implementing fitted.lcModel()transformFitted transformFitted,data.frame,lcModel-method transformFitted,list,lcModel-method transformFitted,matrix,lcModel-method transformFitted,NULL,lcModel-method
Helper function for custom lcModel classes implementing predict.lcModel()transformPredict transformPredict,data.frame,lcModel-method transformPredict,matrix,lcModel-method transformPredict,NULL,lcModel-method transformPredict,vector,lcModel-method
Convert a multiple time series matrix to a data.framemeltRepeatedMeasures tsframe
Convert a longitudinal data.frame to a matrixdcastRepeatedMeasures tsmatrix
Update a method specificationupdate.lcMethod
Update a lcModelupdate.lcModel
'lcMethod' estimation step: method argument validation logicvalidate validate,lcMethod-method
Sample an index of a vector weighted by the elementswhich.weight