Are there any methods or algorithms to cluster longitudinal data where each subject may have different time range? For instance, subject A has observations from time 1 to 5, subject B has observations from time 1 to 7, subject C has observations from time 1 to 8 and so on.

  • $\begingroup$ Survival analysis, maybe $\endgroup$
    – Deep North
    Nov 28, 2017 at 2:34
  • $\begingroup$ Hi, thanks for the reply. I am more interested in the clustering though, where I can see if there are groups of people that have similar trend of outcome throughout time. $\endgroup$
    – soeci92
    Nov 28, 2017 at 3:49
  • $\begingroup$ Hi Can you elaborate as to at what level you want to cluster.What you have here is unbalanced panel data, but clustering shouldnot differ due that. $\endgroup$
    – karsha
    Nov 29, 2017 at 22:37
  • $\begingroup$ The flexmix package in R allows to fit mixtures of all kinds of (generalised) linear models; it maybe that it allows for this task. Have a look at the vignettes. cran.r-project.org/web/packages/flexmix/index.html $\endgroup$ Apr 26 at 19:50

1 Answer 1


You could either

  • Determine a function or set of function to map the longitudinal data to a fixed size. For example, take the mean, max, min, sum, count of a time series. Then, concatenate those values into vectors and cluster the vectors.
  • Learn an embedding that represents the time series, which is similar to the first method except you learn the functions that are used to produce the vector representation, and then cluster the embeddings. To create this embedding you could use a time series model that handles variable-length input (e.g., an RNN).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.