# Random forest for binary panel data

I have a dataset with observations from about 50 countries and 20 years. My dependent variable is binary and I was wondering if I could use random forest to do out-of-sample predictions. My problem is: as far as I know, RF considers observations to be independent, which is not the case in my dataset. Is there any software (preferably an R package) that takes data structure into consideration when doing bootstrap sampling? I was thinking about something like GMERT, random effects combined with RF (see: How can I include random effects into a randomForest). However, due to my limited programming skills, I could not adapt the authors' code to use it with binary response variables. Any suggestions?

• Time-series cross-section in the title plus how you describe your problem calls for a panel-data tag, and perhaps changing the title into something like "Random forest for panel data". Hopefully, that would help you attract the right people to answer your question. – Richard Hardy Jun 12 '15 at 8:14
• Thanks, @RichardHardy! I've just edited the title as you suggested. – danilofreire Jun 13 '15 at 7:49
• I am developing these methods and will keep you posted. – Randel Jul 28 '15 at 5:07
• Is there an analogous package in python? – user0 Jan 8 '17 at 18:34

• The random forest part uses cforest() in the party package since it allows case weights.
• The linearized mixed models are estimated with the lme4 package. So there are many possible options.