Library: | hazreg |
See also: | stree plotstree |
Quantlet: | grstree | |
Description: | generates a survival tree |
Usage: | {cdata,bdata,aldata,ardata,ctext,btext,atext} = grstree(streedata{,col{,fontsize{,varname}}}) | |
Input: | ||
streedata | list of various parameters given from <a href="stree.html">stree</a> and which are necessary for the plotting | |
col | n x 1 vector of colors, col[1] corresponds to the color of the circles, col[2] to the color of their descriptions, col[3] to the color of the boxes, col[4] to the color of their descriptions, col[5] represents the color of the arrows and col[6] their descriptions | |
fontsize | scalar, size of the font used | |
varname | string vector, names of the split variables | |
Output: | ||
cdata | graphical object representing the circles (internal nodes) in the tree | |
bdata | graphical object, the boxes (terminal nodes) in the tree | |
aldata | graphical object, the left arrows in the tree | |
ardata | graphical object, the right arrows in the tree | |
ctext | coordinates of the text in the circles | |
btext | coordinates of the text in the boxes | |
atext | coordinates of the text at the arrows |
nnd...scalar, number of internal nodes in the tree
dt...40 x 1 vector representing the daughter nodes. dt[1] represents the root,
dt[2] the left daughter node of the root and dt[3] the right
daughter node of the root. In general: dt[2*j] points to the left and dt[2*j+1]
to the right daughter node.
pt...40 x 1 vector, parent nodes, indexed like dt
spv...40 x 1 vector, split variable
spvl...40 x 1 vector, split value for numerical variables and split categories
c_1,...,c_k encoded as a number c_1 + c_2 * 10 + ... + c_k * 10^(k-1)
for nominal variables
catg...n x 1 vector, types of the covariates: 1 = numerical (ordinal) variable,
2 = nominal (categorical) variable
ncases...40 x 1 vector, number of cases in the corresponding node
median...40 x 1 vector, median in the corresponding node
deathcatg...100 x 1 vector, number of death observations
vartovar...vector used for printing the text by arrows
library("hazreg") randomize(666) n = 100 p = 4 beta = 1|2|1|2 ; regression parameter z = 1 + uniform(n,p) ; covariates y = -log(1-uniform(n)) ; exponential survival y = y./exp(z*beta) ; covariate effects c = 4*uniform(n) ; uniform censoring t = min(y~c,2) ; censored time delta =(y<=c) ; censoring indicator nom = 0*matrix(30)|matrix(30) nom = nom|2*matrix(40) ctypes = 0|0|0|0|1 ; types of covariates method = "logrank" st=stree(100*z~nom, t, delta, ctypes, method,0) ; no display will be returned streedata=st.groutput ; get the graphical object col = 0*matrix(6) ; black Stree for print fontsize = 12 varname = "apple"|"pear"|"orange"|"lemon"|"dog" gr=grstree(streedata,col,fontsize,varname) c = gr.cdata b = gr.bdata al = gr.aldata ar = gr.ardata ct = gr.ctext bt = gr.btext at = gr.atext sdisp = createdisplay(1,1) axesoff() show(sdisp,1,1,c,b,al,ar) setgopt(sdisp,1,1,"title","Example of a survival tree") axeson()
A black survival tree without any description is plotted together with the following text output. The Survival Tree: ---------------------------------------------------------- ---------------------------------------------------------- Log rank method (before Prune) ---------------------------------------------------------- | |daughter-nodes| median |split | split node #| cases |left right | value | var # | value ---------------------------------------------------------- 1 100 2 3 0.00 2 171.02 2 67 4 5 0.00 1 138.41 3 33 6 7 0.00 4 157.87 4 29 8 9 0.00 4 126.47 5 38 10 11 0.00 4 153.24 7 19 12 13 0.00 3 158.98 9 18 14 15 0.00 3 145.61 10 19 16 17 0.00 5 {2} 11 19 18 19 0.00 3 160.77 ---------------------------------------------------------- Log rank method (after Prune) ---------------------------------------------------------- | |daughter-nodes| median |split | split node #| cases |left right | value | var # | value ---------------------------------------------------------- 1 100 2 3 0.00 2 171.02 2 67 4 5 0.00 1 138.41 3 33 6 7 0.00 4 157.87 4 29 8 9 0.00 4 126.47 5 38 10 11 0.00 4 153.24 11 19 18 19 0.00 3 160.77 ---------------------------------------------------------- ----------------------------------------------------------