0

I am building a model to detect perturbances in a dataset using rpart. below is a simple code:

model1 = rpart(OA~I0+IA,data=data,method="class",control = rpart.control(minsplit = 20, minbucket=1))

The resultant is a tree with "I0" as root node. Is there a way I can generate a tree by fixing the root node to "IA"?

  • 2
    Can I ask why you want to do this? You could simply fit trees in a 2 stage process. 0A~IA then 0A~IO using only subsets of the data from the previous tree's splits. – Bruce Pucci Sep 10 '15 at 20:41
  • Thank you for the reply Bruce. It made sense to use IA as root node than I0 (intuitively). I actually developed a tree by hand which works well with IA as root node. Therefore, I wanted to see if I can force rpart to get my result. I will try your method. How do I subset the data after the first split? Shouldn't I use the same data? – user5322892 Sep 11 '15 at 13:59
  • You do use the same data but subset it based on the split the first model made. ie. the split is at IA <=5 on the first tree. Then build 2 versions of the 2nd tree... 0A~IO where IA <= 5 and OA~IO where IA > 5. – Bruce Pucci Sep 11 '15 at 15:47

0 Answers0