|
a |
|
b/partyMod/man/panelfunctions.Rd |
|
|
1 |
\name{Panel Generating Functions} |
|
|
2 |
\encoding{latin1} |
|
|
3 |
|
|
|
4 |
\alias{node_inner} |
|
|
5 |
\alias{node_terminal} |
|
|
6 |
\alias{edge_simple} |
|
|
7 |
\alias{node_surv} |
|
|
8 |
\alias{node_barplot} |
|
|
9 |
\alias{node_boxplot} |
|
|
10 |
\alias{node_hist} |
|
|
11 |
\alias{node_density} |
|
|
12 |
\alias{node_scatterplot} |
|
|
13 |
\alias{node_bivplot} |
|
|
14 |
|
|
|
15 |
\title{ Panel-Generators for Visualization of Party Trees } |
|
|
16 |
\description{ |
|
|
17 |
The plot method for \code{BinaryTree} and \code{mob} objects are rather |
|
|
18 |
flexible and can be extended by panel functions. Some pre-defined |
|
|
19 |
panel-generating functions of class \code{grapcon_generator} |
|
|
20 |
for the most important cases are documented here. |
|
|
21 |
} |
|
|
22 |
\usage{ |
|
|
23 |
node_inner(ctreeobj, digits = 3, abbreviate = FALSE, |
|
|
24 |
fill = "white", pval = TRUE, id = TRUE) |
|
|
25 |
node_terminal(ctreeobj, digits = 3, abbreviate = FALSE, |
|
|
26 |
fill = c("lightgray", "white"), id = TRUE) |
|
|
27 |
edge_simple(treeobj, digits = 3, abbreviate = FALSE) |
|
|
28 |
node_surv(ctreeobj, ylines = 2, id = TRUE, \dots) |
|
|
29 |
node_barplot(ctreeobj, col = "black", fill = NULL, beside = NULL, |
|
|
30 |
ymax = NULL, ylines = NULL, widths = 1, gap = NULL, |
|
|
31 |
reverse = NULL, id = TRUE) |
|
|
32 |
node_boxplot(ctreeobj, col = "black", fill = "lightgray", |
|
|
33 |
width = 0.5, yscale = NULL, ylines = 3, cex = 0.5, id = TRUE) |
|
|
34 |
node_hist(ctreeobj, col = "black", fill = "lightgray", |
|
|
35 |
freq = FALSE, horizontal = TRUE, xscale = NULL, ymax = NULL, |
|
|
36 |
ylines = 3, id = TRUE, \dots) |
|
|
37 |
node_density(ctreeobj, col = "black", rug = TRUE, |
|
|
38 |
horizontal = TRUE, xscale = NULL, yscale = NULL, ylines = 3, |
|
|
39 |
id = TRUE) |
|
|
40 |
node_scatterplot(mobobj, which = NULL, col = "black", |
|
|
41 |
linecol = "red", cex = 0.5, pch = NULL, jitter = FALSE, |
|
|
42 |
xscale = NULL, yscale = NULL, ylines = 1.5, id = TRUE, |
|
|
43 |
labels = FALSE) |
|
|
44 |
node_bivplot(mobobj, which = NULL, id = TRUE, pop = TRUE, |
|
|
45 |
pointcol = "black", pointcex = 0.5, |
|
|
46 |
boxcol = "black", boxwidth = 0.5, boxfill = "lightgray", |
|
|
47 |
fitmean = TRUE, linecol = "red", |
|
|
48 |
cdplot = FALSE, fivenum = TRUE, breaks = NULL, |
|
|
49 |
ylines = NULL, xlab = FALSE, ylab = FALSE, margins = rep(1.5, 4), \dots) |
|
|
50 |
} |
|
|
51 |
\arguments{ |
|
|
52 |
\item{ctreeobj}{ an object of class \code{BinaryTree}.} |
|
|
53 |
\item{treeobj}{ an object of class \code{BinaryTree} or \code{mob}.} |
|
|
54 |
\item{mobobj}{ an object of class \code{mob}.} |
|
|
55 |
\item{digits}{ integer, used for formating numbers. } |
|
|
56 |
\item{abbreviate}{ logical indicating whether strings should be |
|
|
57 |
abbreviated. } |
|
|
58 |
\item{col, pointcol}{ a color for points and lines. } |
|
|
59 |
\item{fill}{ a color to filling rectangles. } |
|
|
60 |
\item{pval}{ logical. Should p values be plotted?} |
|
|
61 |
\item{id}{ logical. Should node IDs be plotted?} |
|
|
62 |
\item{ylines}{ number of lines for spaces in y-direction. } |
|
|
63 |
\item{widths}{ widths in barplots. } |
|
|
64 |
\item{width, boxwidth}{ width in boxplots. } |
|
|
65 |
\item{gap}{ gap between bars in a barplot (\code{node_barplot}). } |
|
|
66 |
\item{yscale}{ limits in y-direction} |
|
|
67 |
\item{xscale}{ limits in x-direction} |
|
|
68 |
\item{ymax}{ upper limit in y-direction} |
|
|
69 |
\item{beside}{ logical indicating if barplots should be side by side or stacked. } |
|
|
70 |
\item{reverse}{logical indicating whether the order of levels should be reversed |
|
|
71 |
for barplots.} |
|
|
72 |
\item{horizontal}{ logical indicating if the plots should be horizontal. } |
|
|
73 |
\item{freq}{logical; if \code{TRUE}, the histogram graphic is a representation |
|
|
74 |
of frequencies. If \code{FALSE}, probabilities are plotted.} |
|
|
75 |
\item{rug}{logical indicating if a rug representation should be added. } |
|
|
76 |
\item{which}{ numeric or character vector indicating which of the regressor |
|
|
77 |
variables should be plotted (default = all).} |
|
|
78 |
\item{linecol}{ color for fitted model lines.} |
|
|
79 |
\item{cex, pointcex}{character extension of points in scatter plots.} |
|
|
80 |
\item{pch}{plotting character of points in scatter plots.} |
|
|
81 |
\item{jitter}{logical. Should the points be jittered in y-direction?} |
|
|
82 |
\item{labels}{logical. Should axis labels be plotted?} |
|
|
83 |
\item{pop}{logical. Should the panel viewports be popped?} |
|
|
84 |
\item{boxcol}{color for box plot borders.} |
|
|
85 |
\item{boxfill}{fill color for box plots.} |
|
|
86 |
\item{fitmean}{logical. Should lines for the predicted means from the model |
|
|
87 |
be added?} |
|
|
88 |
\item{cdplot}{logical. Should CD plots (or spinograms) be used for visualizing |
|
|
89 |
the dependence of a categorical on a numeric variable?} |
|
|
90 |
\item{fivenum}{logical. When using spinograms, should the five point summary |
|
|
91 |
of the explanatory variable be used for determining the breaks?} |
|
|
92 |
\item{breaks}{a (list of) numeric vector(s) of breaks for the spinograms. If set to \code{NULL} |
|
|
93 |
(the default), the \code{breaks} are chosen according to the \code{fivenum} |
|
|
94 |
argument.} |
|
|
95 |
\item{xlab, ylab}{ character with x- and y-axis labels. Can also be logical: if \code{FALSE} |
|
|
96 |
axis labels are surpressed, if \code{TRUE} they are taken from the underlying data. |
|
|
97 |
Can be a vector of labels for \code{xlab}. } |
|
|
98 |
\item{margins}{margins of the viewports.} |
|
|
99 |
\item{\dots}{ additional arguments passed to callies.} |
|
|
100 |
} |
|
|
101 |
|
|
|
102 |
\details{ |
|
|
103 |
The \code{plot} methods for \code{BinaryTree} and \code{mob} objects provide an |
|
|
104 |
extensible framework for the visualization of binary regression trees. The |
|
|
105 |
user is allowed to specify panel functions for plotting terminal and inner |
|
|
106 |
nodes as well as the corresponding edges. The panel functions to be used |
|
|
107 |
should depend only on the node being visualzied, however, for setting up |
|
|
108 |
an appropriate panel function, information from the whole tree is typically |
|
|
109 |
required. Hence, \pkg{party} adopts the framework of \code{grapcon_generator} |
|
|
110 |
(graphical appearance control) from the \pkg{vcd} package (Meyer, Zeileis and |
|
|
111 |
Hornik, 2005) and provides several panel-generating functions. For convenience, |
|
|
112 |
the panel-generating functions \code{node_inner} and \code{edge_simple} |
|
|
113 |
return panel functions to draw inner nodes and left and right edges. |
|
|
114 |
For drawing terminal nodes, the functions returned by the other panel |
|
|
115 |
functions can be used. The panel generating function \code{node_terminal} |
|
|
116 |
is a terse text-based representation of terminal nodes. |
|
|
117 |
|
|
|
118 |
Graphical representations of terminal nodes are available and depend on |
|
|
119 |
the kind of model and the measurement scale of the variables modelled. |
|
|
120 |
|
|
|
121 |
For univariate regressions (typically fitted by \code{ctree}), |
|
|
122 |
\code{node_surv} returns a functions that plots Kaplan-Meier curves in each |
|
|
123 |
terminal node; \code{node_barplot}, \code{node_boxplot}, \code{node_hist} and |
|
|
124 |
\code{node_density} can be used to plot bar plots, box plots, histograms and |
|
|
125 |
estimated densities into the terminal nodes. |
|
|
126 |
|
|
|
127 |
For multivariate regressions (typically fitted by \code{mob}), |
|
|
128 |
\code{node_bivplot} returns a panel function that creates bivariate plots |
|
|
129 |
of the response against all regressors in the model. Depending on the scale |
|
|
130 |
of the variables involved, scatter plots, box plots, spinograms (or CD plots) |
|
|
131 |
and spine plots are created. For the latter two \code{\link[vcd]{spine}} and |
|
|
132 |
\code{\link[vcd]{cd_plot}} from the \pkg{vcd} package are re-used. |
|
|
133 |
} |
|
|
134 |
|
|
|
135 |
\references{ |
|
|
136 |
David Meyer, Achim Zeileis, and Kurt Hornik (2006). |
|
|
137 |
The Strucplot Framework: Visualizing Multi-Way Contingency Tables with vcd. |
|
|
138 |
\emph{Journal of Statistical Software}, \bold{17}(3). |
|
|
139 |
\url{http://www.jstatsoft.org/v17/i03/} |
|
|
140 |
} |
|
|
141 |
|
|
|
142 |
\examples{ |
|
|
143 |
|
|
|
144 |
set.seed(290875) |
|
|
145 |
|
|
|
146 |
airq <- subset(airquality, !is.na(Ozone)) |
|
|
147 |
airct <- ctree(Ozone ~ ., data = airq) |
|
|
148 |
|
|
|
149 |
## default: boxplots |
|
|
150 |
plot(airct) |
|
|
151 |
|
|
|
152 |
## change colors |
|
|
153 |
plot(airct, tp_args = list(col = "blue", fill = hsv(2/3, 0.5, 1))) |
|
|
154 |
## equivalent to |
|
|
155 |
plot(airct, terminal_panel = node_boxplot(airct, col = "blue", |
|
|
156 |
fill = hsv(2/3, 0.5, 1))) |
|
|
157 |
|
|
|
158 |
### very simple; the mean is given in each terminal node |
|
|
159 |
plot(airct, type = "simple") |
|
|
160 |
|
|
|
161 |
### density estimates |
|
|
162 |
plot(airct, terminal_panel = node_density) |
|
|
163 |
|
|
|
164 |
### histograms |
|
|
165 |
plot(airct, terminal_panel = node_hist(airct, ymax = 0.06, |
|
|
166 |
xscale = c(0, 250))) |
|
|
167 |
} |
|
|
168 |
\keyword{hplot} |