Keywords - Function groups - @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

Library: xclust
See also: cartsplit cartsplitopt cartcv leafnum pred prederr prune prunecv pruneseq prunetot ssr kuva

Macro: maketr
Description: Returns a specified subtree of the given regression tree.

Usage: subcs = maketr(cs, node)
Input:
cs list of vectors: data structure which represents a binary tree and is produced by cartsplit procedure, contains vectors cs.val, cs.vec, cs.mean, cs.ssr, cs.nelem. See cartsplit for the description of cs.
node integer >= 1: specifies a node of the tree cs. The branch growing from this node will be pruned away. If node=1, only the root node will be returned, if node=2, the tree will be pruned below the left child of the root node, if node=3, the tree will be pruned below the left subtree of the left subtree (if it exists). See cartsplit for the explanation how the tree is represented as a vector.
Output:
subcs list of vectors: data structure which represents a binary tree and is produced by cartsplit procedure, contains vectors subcs.val, subcs.vec,subcs.mean, subcs.ssr, subcs.nelem. See cartsplit for the description of subcs. The tree subcs is the result when the leaves of cs, which are below the position specified by the argument "node", are cutted away.

Example:
; load the library xclust
library ("xclust")
;let us generate a tree by cartsplit procedure
x1=#(0,0,0,0,1,1,1,1,1,2)
x2=#(0,0,0,0,0,0,0,1,1,1)
x=x1~x2
y=#(0,0,0,0,100,100,100,120,120,120)
cs=cartsplit(x,y,#(0,1))
cs
subcs=maketr(cs,3)
subcs
Result:

Content of object cs.val.split0
[1,] 0 
[2,] 1,2 
Content of object cs.val.split1
[1,] NaN 
Content of object cs.val.split2
[1,] 0 
Content of object cs.val.split3
[1,] NaN 
Content of object cs.val.split4
[1,] NaN 
Content of object cs.vec
[1,] 1.000000 
[2,] NaN 
[3,] 2.000000 
[4,] NaN 
[5,] NaN 
Contents of cs.mean
[1,] 66.000000 
[2,] 0.000000 
[3,] 110.000000 
[4,] 100.000000 
[5,] 120.000000 
Contents of cs.ssr
[1,] 29640.000000 
[2,] 0.000000 
[3,] 600.000000 
[4,] 0.000000 
[5,] 0.000000 
Contents of cs.nelem
[1,] 10.000000 
[2,] 4.000000 
[3,] 6.000000 
[4,] 3.000000 
[5,] 3.000000 
Contents of subcs.val.split0
[1,] 0 
[2,] 1,2 
Contents of subcs.val.split1
[1,] NaN 
Contents of subcs.val.split2
[1,] NaN 
Contents of subcs.vec
[1,] 1.000000 
[2,] NaN 
[3,] NaN 
Contents of subcs.mean
[1,] 66.000000 
[2,] 0.000000 
[3,] 110.000000 
Contents of subcs.ssr
[1,] 29640.000000 
[2,] 0.000000 
[3,] 600.000000 
Contents of subcs.nelem
[1,] 10.000000 
[2,] 4.000000 
[3,] 6.000000 

Library: xclust
See also: cartsplit cartsplitopt cartcv leafnum pred prederr prune prunecv pruneseq prunetot ssr kuva

Keywords - Function groups - @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

Author: Jussi Klemelae, 980323
(C) MD*TECH Method and Data Technologies, 28.6.1999