1
$\begingroup$

Would any R expert explain the predic function in the randomforest package to me?

I want to get two prediction results for numberic response variable A and B seperately from following regression

result <-randomforest(A + B ~ C + D + E, data = dataset)
predict(result)

I can get one prediction result. But prediction is neither A nor B. I can get the prediction results for both A and B from Mvpart and party package.

Thanks in advance!

$\endgroup$
2
  • 1
    $\begingroup$ The RF algorithm, as implemented in the randomForest package with formula notation, considers one response variable only (factor or numeric). Can you provide more information on the type of variables you have, and what you want to achieve? $\endgroup$
    – chl
    Commented Oct 30, 2012 at 22:53
  • 1
    $\begingroup$ You seem to have lost your account information, James. This is a repost of an earlier question. I will merge your two accounts and merge this question with the other. $\endgroup$
    – chl
    Commented Nov 1, 2012 at 22:35

2 Answers 2

1
$\begingroup$

Build two forests using the same input data and different response variables, one forest for A and one for B.

You can then combine the output of the two trees to create a prediction {A,B}.

$\endgroup$
1
$\begingroup$

Random Forest does not fit multiple response. You need to fit separate models for A and B. In your case Random Forest has treated the sum(A,B) as single dependent variable. So the prediction also corresponds to sum(A,B).

$\endgroup$

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.