Plot that ts your particular needs the default plot

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: want to play around with the spacing with compress, try using nspace which regulates the space between a terminal node and a split. plotfit,branch=.4,uniform=T,compress=T textfit,all=T,use.n=T 47 grade<2.5 g2<13.2 No (52/9) ploidy:ab g2>17.91 g2>11.845 Prog (3/6) g2<11.005 No (6/1) No (12/5) Figure 16: No (14/8) Prog (2/5) Prog (3/20) plotfit, branch=0; textfit,use.n=T grade<2.5 | No (92/54) g2<13.2 Prog (40/45) No (52/9) g2>17.91 Prog (17/28) ploidy:ab No (23/17) g2>11.845 No (20/11) Prog (3/6) No (14/8) g2<11.005 No (14/10) No (6/1) No (12/5) Figure 17: Prog (2/5) plotfit, branch=.4, uniform=T,compress=T 48 Prog (3/20) Endpoint = progstat No | (92/54) grade<2.5 grade>2.5 No Prog (52/9) (40/45) g2<13.2 g2>13.2 No (23/17) ploidy:ab ploidy:c No Prog (20/11) (3/6) g2>11.845 g2<11.845 No No (6/1) (14/10) g2<11.005 g2>11.005 No Prog (12/5) (2/5) Prog (17/28) g2>17.91 g2<17.91 No Prog (14/8) (3/20) Figure 18: postfit We have combined several of these options into a function called post.rpart. Results are shown in gure 18. The code is essentially plottree, uniform = T, branch = 0.2, compress = T, margin = 0.1 texttree, all = T, use.n=T, fancy = T The fancy option of text creates the ellipses and rectangles, and moves the splitting rule to the midpoints of the branches. Margin shrinks the plotting region slightly so that the text boxes don't run over the edge of the plot. The branch option makes the lines exit the ellipse at a good" angle. The call postfit will create a postcript le t.ps in the current directory. The additional argument file="" will cause the plot to appear on the current active device. Note that post.rpart is just our choice of options to the functions plot.rpart and text.rpart. The reader is encouraged to try out other possibilities, as these speci cations may not be the best choice in all situations. 10 Other functions A more general approach to cross-validation can be gained using the xpred.rpart function. Given an rpart t, a vector of k complexity parameters, and the desired number of cross-validation groups, this function returns an n by k matrix containing 49 the predicted value y,i for each subject, from the model that was t without that ^ subject. The cp vector defaults to the geometric mean of the cp sequence for the pruned tree on the full data set. 1 2 3 4 5 fit - rpartpgtime ~ age + fit$cptable CP nsplit rel error 0.07572983 0 1.0000000 0.02825076 2 0.8485403 0.01789441 7 0.7219625 0.01295145 8 0.7040681 0.01000000 9 0.6911166 eet + g2 + grade + gleason + ploidy, stagec xerror 1.012323 1.094811 1.216495 1.223120 1.227213 xstd 0.1321533 0.1547652 0.1603581 0.1610315 0.1660616 temp - xpred.rpartfit err - stagec$pgtime - temp^2 sum.err - applyerr,2,sum sum.err fit$frame$dev 1 0.27519053 0.04625392 0.02248401 0.01522362 0.01138044 1.021901 1.038632 1.14714 1.179571 1.174196 The answer from xpred.rpart di ers from the model's computation due to different random number seeds, which...
View Full Document

Ask a homework question - tutors are online