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'.


2 Answers 2


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.

  • $\begingroup$ 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 $\endgroup$
    – yoyo
    Commented Jun 29, 2013 at 13:04
  • $\begingroup$ I see. Could you just aggregate your data at the household level, so that each household is a sample, before modeling it? $\endgroup$
    – Mina
    Commented Jul 2, 2013 at 17:47
  • $\begingroup$ I don't think it's possible. I think I will lost a lot of the information contained in my data $\endgroup$
    – yoyo
    Commented Jul 4, 2013 at 13:35

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.