Panel Generating Functions       package:party       R Documentation

_P_a_n_e_l-_G_e_n_e_r_a_t_o_r_s _f_o_r _V_i_s_u_a_l_i_z_a_t_i_o_n _o_f _P_a_r_t_y _T_r_e_e_s

_D_e_s_c_r_i_p_t_i_o_n:

     The plot method for 'BinaryTree' and 'mob' 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.

_U_s_a_g_e:

     node_inner(ctreeobj, digits = 3, abbreviate = FALSE, 
       fill = "white", pval = TRUE, id = TRUE)
     node_terminal(ctreeobj, digits = 3, abbreviate = FALSE, 
       fill = c("lightgray", "white"), id = TRUE)
     edge_simple(treeobj, digits = 3, abbreviate = FALSE)
     node_surv(ctreeobj, ylines = 2, id = TRUE, ...)
     node_barplot(ctreeobj, col = "black", fill = "lightgray", ymax = NULL,
       ylines = 3, widths = 1, gap = NULL, id = TRUE)
     node_boxplot(ctreeobj, col = "black", fill = "lightgray",  width = 0.5,
       yscale = NULL, ylines = 3, cex = 0.5, id = TRUE)
     node_hist(ctreeobj, col = "black", fill = "lightgray", freq = FALSE,
       horizontal = TRUE, xscale = NULL, ymax = NULL, ylines = 3,
       id = TRUE, ...)
     node_density(ctreeobj, col = "black", rug = TRUE, horizontal = TRUE,
       xscale = NULL, yscale = NULL, ylines = 3, id = TRUE)

     node_scatterplot(mobobj, which = NULL, col = "black", linecol = "red",
       cex = 0.5, pch = NULL, jitter = FALSE, xscale = NULL, yscale = NULL, ylines = 1.5,
       id = TRUE, labels = FALSE)
     node_bivplot(mobobj, which = NULL, id = TRUE, pop = TRUE,
       pointcol = "black", pointcex = 0.5,
       boxcol = "black", boxwidth = 0.5, boxfill = "lightgray",
       fitmean = TRUE, linecol = "red",
       cdplot = FALSE, fivenum = TRUE, breaks = NULL, ...)

_A_r_g_u_m_e_n_t_s:

ctreeobj: an object of class 'BinaryTree'.

 treeobj: an object of class 'BinaryTree' or 'mob'.

  mobobj: an object of class 'mob'.

  digits: integer, used for formating numbers. 

abbreviate: logical indicating whether strings should be  abbreviated. 

col, pointcol: a color for points and lines. 

    fill: a color to filling rectangles. 

    pval: logical. Should p values be plotted?

      id: logical. Should node IDs be plotted?

  ylines: number of lines for spaces in y-direction. 

  widths: widths in barplots. 

width, boxwidth: width in boxplots. 

     gap: gap between bars in a barplot ('node_barplot'). 

  yscale: limits in y-direction

  xscale: limits in x-direction

    ymax: upper limit in y-direction

horizontal: logical indicating if the plots should be horizontal. 

    freq: logical; if 'TRUE', the histogram graphic is a representation
          of frequencies. If 'FALSE', probabilities are plotted.

     rug: logical indicating if a rug representation should be added. 

   which: numeric or character vector indicating which of the regressor
          variables should be plotted (default = all).

 linecol: color for fitted model lines.

cex, pointcex: character extension of points in scatter plots.

     pch: plotting character of points in scatter plots.

  jitter: logical. Should the points be jittered in y-direction?

  labels: logical. Should axis labels be plotted?

     pop: logical. Should the panel viewports be popped?

  boxcol: color for box plot borders.

 boxfill: fill color for box plots.

 fitmean: logical. Should lines for the predicted means from the model
          be added?

  cdplot: logical. Should CD plots (or spinograms) be used for
          visualizing the dependence of a categorical on a numeric
          variable?

 fivenum: logical. When using spinograms, should the five point summary
          of the explanatory variable be used for determining the
          breaks?

  breaks: a (list of) numeric vector(s) of breaks for the spinograms.
          If set to 'NULL' (the default), the 'breaks' are chosen
          according to the 'fivenum' argument.

     ...: additional arguments passed to callies.

_D_e_t_a_i_l_s:

     The 'plot' methods for 'BinaryTree' and 'mob' 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
     visualzied, 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 modelled.

     For univariate regressions (typically fitted by 'ctree'),
     'node_surv' returns a functions that plots Kaplan-Meier curves in
     each  terminal node; 'node_barplot', 'node_boxplot', 'node_hist'
     and 'node_density' can be used to plot bar plots, box plots,
     histograms 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.

_R_e_f_e_r_e_n_c_e_s:

     Meyer, D., Zeileis, A., and Hornik, K. (2005) The strucplot
     framework: Visualizing multi-way contingency tables with vcd.
     _Report 22_, Department of Statistics and Mathematics, 
     Wirtschaftsuniversitaet Wien, Research Report Series. <URL:
     http://epub.wu-wien.ac.at/dyn/openURL?id=oai:epub.wu-wien.ac.at:ep
     ub-wu-01_8a1>

_E_x_a_m_p_l_e_s:

       airq <- subset(airquality, !is.na(Ozone))
       airct <- ctree(Ozone ~ ., data = airq)

       ## default: boxplots
       plot(airct)
       
       ## change colors
       plot(airct, tp_args = list(col = "blue", fill = hsv(2/3, 0.5, 1)))
       ## equivalent to
       plot(airct, terminal_panel = node_boxplot(airct, col = "blue", fill = hsv(2/3, 0.5, 1)))

       ### very simple; the mean is given in each terminal node
       plot(airct, type = "simple")

       ### density estimates
       plot(airct, terminal_panel = node_density)
         
       ### histograms 
       plot(airct, terminal_panel = node_hist(airct, ymax = 0.06, xscale = c(0, 250)))

