# Random Forest and cluster-level bootstrapping

I'm working with cluster-correlated data (individuals nested into households). I would like to modify the bootstrap sampling process to make a household-level bootstrap instead of the subject-level bootstrap.

My aim is to ensure that the entire household is included in the sample used to grow each tree of the forest. I'm working with R package 'randomForest'.

Your question seems to be addressed in the paper "An Introspective Comparison of Random Forest-Based Classifiers for the Analysis of Cluster-Correlated Data by Way of RF++" available here. Those authors addressed the question with "subject-level bootstrapping". They wrote their own software which I have not used (so I can't vouch for it) and was updated last in 2009. I'd feel more comfortable just writing my own bootstrapping code and using a well maintained random forest package.

If you want to use R, you could just write your own code to bootstrap subject-level sampling and set the parameter replace=FALSE in the randomForest function. Sample household IDs (with replacement) and then within each household include all individuals. Build a RF with that training data, and use the RF to predict the values of the individuals from unsampled households. Repeat that whole process 10 or so times so that each individual has several RF predictions, and combine all of those into a single prediction. That seems to be the general approach taken in the paper referenced above.

Have you looked into using the strata and sampsize parameters from the R package 'random forest'? You could indicate household in the strata parameter.

This is copied from the R documentation on the randomForest package:

strata: A (factor) variable that is used for stratified sampling.

sampsize: Size(s) of sample to draw. For classification, if sampsize is a vector of the length the number of strata, then sampling is stratified by strata, and the elements of sampsize indicate the numbers to be drawn from the strata.

• Thank you for your answer. I don't think this option is appropriate for my problem. I think the "strata" and "sampsize" options are more appropriate with factor such as "sex" or "age class" to ensure that each class has the same probability to be sampled. Am I wrong ? My aim was to ensure that all individuals in a household are still part of the bootstrap sample used to construct each tree. Thank you – yoyo Jun 29 '13 at 13:04
• I see. Could you just aggregate your data at the household level, so that each household is a sample, before modeling it? – Mina Jul 2 '13 at 17:47
• I don't think it's possible. I think I will lost a lot of the information contained in my data – yoyo Jul 4 '13 at 13:35