Switch to unified view

a b/partyMod/man/plot.BinaryTree.Rd
1
\name{Plot BinaryTree}
2
\encoding{latin1}
3
4
\alias{plot.BinaryTree}
5
6
\title{ Visualization of Binary Regression Trees }
7
8
\description{
9
  \code{plot} method for \code{BinaryTree} objects with
10
  extended facilities for plugging in panel functions.
11
}
12
13
\usage{
14
\method{plot}{BinaryTree}(x, main = NULL, type = c("extended", "simple"),
15
     terminal_panel = NULL, tp_args = list(),
16
     inner_panel = node_inner, ip_args = list(),
17
     edge_panel = edge_simple, ep_args = list(),
18
     drop_terminal = (type[1] == "extended"), 
19
     tnex = (type[1] == "extended") + 1, newpage = TRUE,  
20
     pop = TRUE, \dots)
21
}
22
23
\arguments{
24
  \item{x}{ an object of class \code{BinaryTree}.}
25
  \item{main}{ an optional title for the plot.}
26
  \item{type}{ a character specifying the complexity of the plot:
27
               \code{extended} tries to visualize the distribution of the
28
               response variable in each terminal node whereas \code{simple} 
29
               only gives some summary information.}
30
  \item{terminal_panel}{ an optional panel function of the form 
31
                         \code{function(node)} plotting the terminal nodes.
32
                         Alternatively, a panel generating function of class
33
             \code{"grapcon_generator"} that is called with arguments
34
             \code{x} and \code{tp_args} to set up a panel function.
35
             By default, an appropriate panel function is chosen 
36
             depending on the scale of the dependent variable.}
37
  \item{tp_args}{ a list of arguments passed to \code{terminal_panel} if this
38
                  is a \code{"grapcon_generator"} object.}
39
  \item{inner_panel}{ an optional panel function of the form 
40
                         \code{function(node)} plotting the inner nodes.
41
                         Alternatively, a panel generating function of class
42
             \code{"grapcon_generator"} that is called with arguments
43
             \code{x} and \code{ip_args} to set up a panel function.}
44
  \item{ip_args}{ a list of arguments passed to \code{inner_panel} if this
45
                  is a \code{"grapcon_generator"} object.}
46
  \item{edge_panel}{ an optional panel function of the form 
47
                    \code{function(split, ordered = FALSE, left = TRUE)}
48
                    plotting the edges.
49
                    Alternatively, a panel generating function of class
50
            \code{"grapcon_generator"} that is called with arguments
51
            \code{x} and \code{ip_args} to set up a panel function.}               
52
  \item{ep_args}{ a list of arguments passed to \code{edge_panel} if this
53
                  is a \code{"grapcon_generator"} object.}
54
  \item{drop_terminal}{ a logical indicating whether all terminal nodes
55
                        should be plotted at the bottom.}
56
  \item{tnex}{a numeric value giving the terminal node extension in relation
57
    to the inner nodes.}
58
  \item{newpage}{ a logical indicating whether \code{grid.newpage()} should be called. }
59
  \item{pop}{ a logical whether the viewport tree should be popped before
60
              return. }
61
  \item{\dots}{ additional arguments passed to callies.}
62
}
63
64
\details{
65
  This \code{plot} method for \code{BinaryTree} objects provides an
66
  extensible framework for the visualization of binary regression trees. The
67
  user is allowed to specify panel functions for plotting terminal and inner
68
  nodes as well as the corresponding edges. Panel functions for plotting
69
  inner nodes, edges and terminal nodes are available for the most important
70
  cases and can serve as the basis for user-supplied extensions, see
71
  \code{\link{node_inner}} and \code{vignette("party")}.
72
73
  More details on the ideas and concepts of panel-generating functions and
74
  \code{"grapcon_generator"} objects in general can be found in Meyer, Zeileis
75
  and Hornik (2005).
76
}
77
78
\references{
79
  David Meyer, Achim Zeileis, and Kurt Hornik (2006).
80
  The Strucplot Framework: Visualizing Multi-Way Contingency Tables with vcd.
81
  \emph{Journal of Statistical Software}, \bold{17}(3).
82
  \url{http://www.jstatsoft.org/v17/i03/}
83
}
84
85
86
\seealso{\code{\link{node_inner}}, \code{\link{node_terminal}}, \code{\link{edge_simple}}, 
87
  \code{\link{node_surv}}, \code{\link{node_barplot}}, \code{\link{node_boxplot}}, 
88
  \code{\link{node_hist}}, \code{\link{node_density}}}
89
90
\examples{
91
92
  set.seed(290875)
93
94
  airq <- subset(airquality, !is.na(Ozone))
95
  airct <- ctree(Ozone ~ ., data = airq)
96
97
  ### regression: boxplots in each node
98
  plot(airct, terminal_panel = node_boxplot, drop_terminal = TRUE)
99
100
  if(require("TH.data")) {
101
  ## classification: barplots in each node
102
  data("GlaucomaM", package = "TH.data")
103
  glauct <- ctree(Class ~ ., data = GlaucomaM)
104
  plot(glauct)
105
  plot(glauct, inner_panel = node_barplot,
106
    edge_panel = function(ctreeobj, ...) { function(...) invisible() },
107
    tnex = 1)
108
109
  ## survival: Kaplan-Meier curves in each node
110
  data("GBSG2", package = "TH.data")
111
  library("survival")
112
  gbsg2ct <- ctree(Surv(time, cens) ~ ., data = GBSG2)
113
  plot(gbsg2ct)
114
  plot(gbsg2ct, type = "simple")  
115
  }
116
117
}
118
\keyword{hplot}