Learn R Programming

partykit (version 1.2-16)

panelfunctions: Panel-Generators for Visualization of Party Trees

Description

The plot method for party and constparty objects are rather flexible and can be extended by panel functions. Some pre-defined panel-generating functions of class grapcon_generator for the most important cases are documented here.

Usage

node_inner(obj, id = TRUE, pval = TRUE, abbreviate = FALSE, fill = "white", 
  gp = gpar())

node_terminal(obj, digits = 3, abbreviate = FALSE, fill = c("lightgray", "white"), id = TRUE, just = c("center", "top"), top = 0.85, align = c("center", "left", "right"), gp = NULL, FUN = NULL, height = NULL, width = NULL)

edge_simple(obj, digits = 3, abbreviate = FALSE, justmin = Inf, just = c("alternate", "increasing", "decreasing", "equal"), fill = "white")

node_boxplot(obj, col = "black", fill = "lightgray", bg = "white", width = 0.5, yscale = NULL, ylines = 3, cex = 0.5, id = TRUE, mainlab = NULL, gp = gpar())

node_barplot(obj, col = "black", fill = NULL, bg = "white", beside = NULL, ymax = NULL, ylines = NULL, widths = 1, gap = NULL, reverse = NULL, rot = 0, just = c("center", "top"), id = TRUE, mainlab = NULL, text = c("none", "horizontal", "vertical"), gp = gpar())

node_surv(obj, col = "black", bg = "white", yscale = c(0, 1), ylines = 2, id = TRUE, mainlab = NULL, gp = gpar(), ...)

node_ecdf(obj, col = "black", bg = "white", ylines = 2, id = TRUE, mainlab = NULL, gp = gpar(), ...)

node_bivplot(mobobj, which = NULL, id = TRUE, pop = TRUE, pointcol = "black", pointcex = 0.5, boxcol = "black", boxwidth = 0.5, boxfill = "lightgray", bg = "white", fitmean = TRUE, linecol = "red", cdplot = FALSE, fivenum = TRUE, breaks = NULL, ylines = NULL, xlab = FALSE, ylab = FALSE, margins = rep(1.5, 4), mainlab = NULL, ...)

node_mvar(obj, which = NULL, id = TRUE, pop = TRUE, ylines = NULL, mainlab = NULL, varlab = TRUE, bg = "white", ...)

Arguments

obj

an object of class party.

digits

integer, used for formating numbers.

abbreviate

logical indicating whether strings should be abbreviated.

col, pointcol, boxcol, linecol

a color for points and lines.

fill, boxfill, bg

a color to filling rectangles and backgrounds.

id

logical. Should node IDs be plotted?

pval

logical. Should node p values be plotted (if they are available)?

just

justification of terminal panel viewport (node_terminal), or labels (edge_simple, node_barplot).

justmin

minimum average edge label length to employ justification via just in edge_panel, otherwise just = "equal" is used. Thus, by default "equal" justification is always used but other justifications could be employed for finite justmin.

top

in case of top justification, the npc coordinate at which the viewport is justified.

align

alignment of text within terminal panel viewport.

ylines

number of lines for spaces in y-direction.

widths

widths in barplots.

boxwidth

width in boxplots (called width in node_boxplot).

gap

gap between bars in a barplot (node_barplot).

yscale

limits in y-direction

ymax

upper limit in y-direction

cex, pointcex

character extension of points in scatter plots.

beside

logical indicating if barplots should be side by side or stacked.

reverse

logical indicating whether the order of levels should be reversed for barplots.

rot

arguments passed to grid.text for the x-axis labeling.

gp

graphical parameters.

FUN

function for formatting the info, passed to formatinfo_node.

height, width

numeric, number of lines/columns for printing text.

mobobj

an object of class modelparty as computed by mob.

which

numeric or character. Optional selection of subset of regressor variables. By default one panel for each regressor variable is drawn.

pop

logical. Should the viewports in the individual nodes be popped after drawing?

fitmean

logical. Should the fitted mean function be visualized?

cdplot

logical. Should a CD plot (or a spineplot) be drawn when the response variable is categorical?

fivenum

logical. Should the five-number summary be used for splitting the x-axis in spineplots?

breaks

numeric. Optional numeric vector with breaks for the x-axis in splineplots.

xlab, ylab

character. Optional annotation for x-axis and y-axis.

margins

numeric. Margins around drawing area in viewport.

mainlab

character or function. An optional title for the plot. Either a character or a function(id, nobs).

varlab

logical. Should the individual variable labels be attached to the mainlab for multivariate responses?

text

logical or character. Should percentage labels be drawn for each bar? The default is "none" or equivalently FALSE. Can be set to TRUE (or "horizontal") or alternatively "vertical".

...

additional arguments passed to callies (for example to survfit).

Details

The plot methods for party and constparty objects provide an extensible framework for the visualization of binary regression trees. The user is allowed to specify panel functions for plotting terminal and inner nodes as well as the corresponding edges. The panel functions to be used should depend only on the node being visualized, however, for setting up an appropriate panel function, information from the whole tree is typically required. Hence, party adopts the framework of grapcon_generator (graphical appearance control) from the vcd package (Meyer, Zeileis and Hornik, 2005) and provides several panel-generating functions. For convenience, the panel-generating functions node_inner and edge_simple return panel functions to draw inner nodes and left and right edges. For drawing terminal nodes, the functions returned by the other panel functions can be used. The panel generating function node_terminal is a terse text-based representation of terminal nodes.

Graphical representations of terminal nodes are available and depend on the kind of model and the measurement scale of the variables modeled.

For univariate regressions (typically fitted by ), node_surv returns a functions that plots Kaplan-Meier curves in each terminal node; node_barplot, node_boxplot, node_hist, node_ecdf and node_density can be used to plot bar plots, box plots, histograms, empirical cumulative distribution functions and estimated densities into the terminal nodes.

For multivariate regressions (typically fitted by mob), node_bivplot returns a panel function that creates bivariate plots of the response against all regressors in the model. Depending on the scale of the variables involved, scatter plots, box plots, spinograms (or CD plots) and spine plots are created. For the latter two spine and cd_plot from the vcd package are re-used.

For multivariate responses in ctree, the panel function node_mvar generates one plot for each response.

References

Meyer D, Zeileis A, Hornik K (2006). The Strucplot Framework: Visualizing Multi-Way Contingency Tables with vcd. Journal of Statistical Software, 17(3), 1--48. tools:::Rd_expr_doi("10.18637/jss.v017.i03")