I have read at many places that tree is good for uncovering complex dependencies among predictor variables. From Tree models in R:
The recursive structure of CART models is ideal for uncovering complex dependencies among predictor variables. If the effect of, say, soil moisture content depends strongly on soil texture in nonlinear fashion, CART models of species occurrences have a better shot at detecting this than interaction terms in GLMs or even GAMs.
However the tree()
function from the tree package doesn't seem to accept the interaction term and reports error “trees cannot handle interaction terms”. Is there a way to include interaction term in tree?
> dat = read.csv("~/Downloads/treedata.csv")
> tree(cover~(elev+plotsize+disturb),data=dat)
node), split, n, deviance, yval
* denotes terminal node
1) root 8971 39740 4.006
2) elev < 1157.5 6875 29610 3.868 *
3) elev > 1157.5 2096 9567 4.460 *
> tree(cover~(elev+plotsize+disturb)^2,data=dat)
Error in tree(cover ~ (elev + plotsize + disturb)^2, data = dat) :
trees cannot handle interaction terms