Skip to content
Prev 33431 / 398513 Next

User-defined functions in rpart

This question concerns rpart's facility for user-defined functions that
accomplish splitting.

I was interested in modifying the code so that in each terminal node,
a linear regression is fit to the data.

It seems that from the allowable inputs in the user-defined functions,
that this may not be possible, since they have the form:

function(y, wt, parms)  (in the case of the "evaluation" function)
function(y, wt, x, parms, continuous)  (split function)

The problem is that there seems to be no facility to include an X
matrix (in the split function, x is a vector corresponding to one
predictor).  Without that, fitting a linear model in the terminal node
would not be possible.

Is this a correct assesment, or am I missing something?
Has anyone tried to modify rpart to fit linear models in nodes?


--