Edit a node on a binary tree and regrow the subtrees below the node to reflect the change.
USAGE:
edit.tree(object, node, var, splitl, splitr = NULL)
REQUIRED ARGUMENTS:
object
fitted model object of class
tree. This is assumed to
be the result of some function that produces an object
with the same named components as that returned by the
tree function.
node
number of the node to edit.
Specifically,
node is a row from a component of the output of
burl.tree.
var
character string giving the variable to split on at the supplied
node.
splitl
left split. For continuous variables, the numeric value of the
split. For factors, a character string of levels. For example,
if levels 2 and 4 should go left,
splitl is "bd".
splitr
right split (only required if
var is a factor). A character string
of levels that go right.
VALUE:
Returns a revised tree with the appropriate node edited.
The left and right subtrees below the supplied node are
regrown to reflect the change.
SEE ALSO:
,
,
.
EXAMPLES:
f.cu <- formula(Reliability ~ Price + Country + Mileage + Type)
#edit node 3 to split on Price < 13000
z.cu <- tree(f.cu, cu.summary, na.action = na.tree.replace)
z.edit <- edit.tree(z.cu, 3, "Price", 13000)
#compute alternative splits at node 3
tree.screens()
b3 <- burl.tree(z.cu, 3)
#edit z.cu according to the 6th split on Country
z.edit <- edit.tree(z.cu, b3$Country[6, ])