I was wondering if there were any machine learning techniques (unsupervised) for modelling longitudinal data? I've always used mixed effects models (mostly non-linear) but I was wondering if there are any other ways of doing this (using machine learning).

By machine learning, I mean random forest, classification/clustering, decision trees and even deep learning, etc.

  • $\begingroup$ Can you please define what you mean by "machine learning"? You can boost an LME after appropriate stratification. That would be pretty novel actually! $\endgroup$
    – usεr11852
    Jun 21, 2016 at 16:35
  • $\begingroup$ @usεr11852, I've added a bit more explanation to the question-hopefully this clarifies it a bit more. $\endgroup$
    – John_dydx
    Jun 21, 2016 at 16:38
  • $\begingroup$ Ah... so boosting is not ML according to your definition. Cool Thanks for the clarification hopefully it will get some attention soon. $\endgroup$
    – usεr11852
    Jun 21, 2016 at 17:45
  • $\begingroup$ ... and boosting too. $\endgroup$
    – John_dydx
    Jun 21, 2016 at 18:20
  • 3
    $\begingroup$ This question appears quite vague. "Machine learning" is a broad term, and even the categories of "random forest, classification/clustering, decision trees and even deep learning, etc." are fairly broad. Is there a clear application that you're interested in? If, for example, you need to classify dichotomous output, you can use a logistic mixed effects model or a logistic GEE. Machine learning and statistical models aren't necessarily to different things. $\endgroup$
    – Jon
    Jan 20, 2017 at 18:45

2 Answers 2


In the case where there are multiple observations from one subject (e.g., multiple visits from the same patient), then the 'patient id' is a 'grouping' variable. Care must be taken during model evaluation so that visits from the same patient do not appear in both the training and testing data, because these are correlated and will lead to inflation of classifier accuracy.

The cross-validation sklearn documentation has cross-validation iterators for grouped data. See GroupKFold, LeaveOneGroupOut, and LeavePGroupsOut.

Even better, try Recurrent Neural Networks or Hidden Markov Models.


You can model your longitudinal with standard machine learning methods by just adding features, that represent the longitudinality, e.g. by adding a feature that represents the time. Or a feature that indicates the membership to a group, person etc (in the panel data case).

If you are creative with feature creation/extraction you can model anything with ML-algorithms.

  • 2
    $\begingroup$ @PhlippePro, I am a bit confused about this answer. (1) What if you want to predict for a person not in your training set? You only have coefficients for those in your training set, right? (2) Adding a feature that corresponds to person might result in addition of up to 100,000 new dummy variables, assuming you have 100,000 people in your dataset. These new features would just be fit right alongside the original ones? $\endgroup$ Jan 17, 2017 at 16:50
  • 1
    $\begingroup$ (1) If you do not have the persons that you want to predict in your training dataset, then you cannot use the "person feature", that is correct. (2) Instead of making dummy features, you can make one "categorical" feature (e.g. you specify them as categorical with as.factor in R). Some algorithms cannot handle so many categories (like e.g. randomForest only can handle approximately 50), then you really have to specify them as dummy variables and you can get (too) many features, as you pointed out. $\endgroup$
    – PhilippPro
    Jan 24, 2017 at 8:15
  • 1
    $\begingroup$ ML doesn't translate so easily into longitudinal data $\endgroup$
    – Aksakal
    Oct 4, 2017 at 1:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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