# Random Forest with longitudinal data

I have many measurements for multiple individuals, but I'm not sure how to account for that repeat-measure structure when running a random forest model.

Is there a way to account for underlying data structure of longitudinal data using a random forest model?

Is this even necessary? -- it seems to me that it should be...

I would especially like to be able to perform this in R.

• Note: I kept this short and simple to see if I could finally attract some responses to a question. If someone desires more info or extension of this question, please comment vs. downvoting. Again, it's not short due to lack of prior research, but because I want people to actually respond to it... :p Nov 9, 2016 at 21:19
• Can you elaborate on what your goal is with this analysis? Nov 9, 2016 at 21:59
• My Goal is to produce a predictive model. the model would predict tree height from tree diameter, given the tree's species and plot location. Each tree is sampled multiple times across decades, so measurements are clustered within individuals. Nov 9, 2016 at 22:41
• Why insist on using random forests with time series at all? There is a deep literature in statistics on multiple imputation in time series, not to mention the multitude of existing methods for time series modeling and prediction. Using RFs ignores that history while, in effect, rebuilding it with a blunter instrument. Just because you have a hammer (RFs), not everything is a nail. Jan 13, 2017 at 14:30
• Ok...the literature on multiple imputation probably starts with Little and Rubin's excellent book, Statistical Analysis with Missing Data. There, they develop the now canonical notions of MAR, MCAR, etc. More recently, Paul Allison's highly readable Sage book, Multiple Imputation for Missing Data has a good review of the literature up through the time it was pub'd. More recently, Sorjana's Methodologies for Time Series Prediction and Missing Value Imputation comes recommended but I am not familiar with it. Jan 13, 2017 at 16:02

There is a previous post that discussed including mixed-effects for clustered/longitudinal data.

How can I include random effects into a randomForest

Here is a good reference for decision tree implementations in R: http://statistical-research.com/a-brief-tour-of-the-trees-and-forests/

Also, you may want to review these slides http://www2.ims.nus.edu.sg/Programs/014swclass/files/denis.pdf

You could try the following packages in R:

• REEMtree: which is no random forest but a single tree model where differences between objects are accounted for over time (so called random or mixed effects), and several trees could possible be ensembled, or

• glmertree: like approaches that can account for segment-wise constant means - which could be adapted to account for individual specific growth patterns (see here).

Or you simply put age as a variable in your model to account for at least that bit of the individual tree characteristic?