cotabplot                package:vcd                R Documentation

_C_o_p_l_o_t _f_o_r _C_o_n_t_i_n_g_e_n_c_y _T_a_b_l_e_s

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

     'cotabplot' is a generic function for creating trellis-like
     coplots (conditional plots) for contingency tables.

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

     cotabplot(x, ...)
     ## Default S3 method:
     cotabplot(x, cond = NULL,
       panel = cotab_mosaic, panel_args = list(),
       margins = rep(1, 4),
       text_gp = gpar(fontsize = 12), rect_gp = gpar(fill = grey(0.9)),
       pop = TRUE, newpage = TRUE,
       ...)
     ## S3 method for class 'formula':
     cotabplot(formula, data = NULL, ...)

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

       x: an object. The default method can deal with contingency
          tables in array form.

    cond: margin index(es) or corresponding name(s) of the conditioning
          variables.

   panel: panel function applied for each conditioned plot, see
          details.

panel_args: list of arguments passed to 'panel' if this is a
          panel-generating function inheriting from class
          '"panel_generator"'.

 margins: either an object of class '"unit"' of length 4, or a numeric
          vector of length 4. The elements are recycled as needed.
          giving the margins around the whole plot.

 text_gp: object of class '"gpar"' used for the text in the panel
          titles.

 rect_gp: object of class '"gpar"' used for the rectangles with the
          panel titles.

     pop: logical indicating whether the generated viewport tree should
          be removed at the end of the drawing or not.

 newpage: logical controlling whether a new grid page should be
          created.

     ...: further arguments passed to the panel-generating function.

 formula: a formula specifying the variables used to create a 
          contingency table from 'data'. It has to be of type '~ x + y
          | z' where 'z' is/are the conditioning variable(s) used.

    data: either a data frame, or an object of class '"table"' or
          '"ftable"'.

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

     'cotabplot' is a generic function designed to create coplots or
     conditional plots (see Cleveland, 1993, and Becker, Cleveland,
     Shyu, 1996) similar to 'coplot' but for contingency tables.

     'cotabplot' takes on computing the conditioning information  and
     setting up the trellis display, and then relies on a panel
     function to create plots from the full table and the conditioning
     information. A simple example would be a contingency table 'tab'
     with margin names '"x"', '"y"' and '"z"'. To produce this plot
     either the default interface can be used or the formula interface
     via

     'cotabplot(tab, "z")' 'cotabplot(~ x + y | z, data = tab)'

     The panel function needs to be of the form

     'panel(x, condlevels)'

     where 'x' is the _full_ table ('tab' in the example above) and
     'condlevels' is a named vector with the levels (e.g.,  'c(z =
     "z1")' in the example above). 

     Alternatively, 'panel' can also be a panel-generating function of
     class '"panel_generator"' which creates a function with the
     interface described above. The panel-generating function is called
     with the interface

     'panel(x, condvars, ...)'

     where again 'x' is the full table, 'condvars' is now only a vector
     with the names of the conditioning variables (and not their
     levels, e.g., '"z"' in the example above). Further arguments can
     be passed to the panel-generating function via '...' which also
     includes the arguments set in 'panel_args'.

     Suitable panel-generating functions for mosaic, association and
     sieve plots can be found at 'cotab_mosaic'.

     A description of the underlying ideas is given in Zeileis, Meyer,
     Hornik (2005).

_A_u_t_h_o_r(_s):

     Achim Zeileis Achim.Zeileis@R-project.org

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

     Becker, R.A., Cleveland, W.S., Shyu, M.-J. (1996), The visual
     design and control of trellis display. _Journal of Computational
     and Graphical Statistics_, *5*, 123-155.

     Cleveland, W.S. (1993), _Visualizing Data_, Summit, New Jersey:
     Hobart Press.

     Zeileis, A., Meyer, D., Hornik K. (2005), _Residual-based shadings
     for visualizing (conditional) independence_, Research Report,
     *20*. <URL: http://epub.wu-wien.ac.at/>

_S_e_e _A_l_s_o:

     'cotab_mosaic', 'cotab_coindep', 'co_table', 'coindep_test'

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

     data(UCBAdmissions)

     cotabplot(~ Admit + Gender | Dept, data = UCBAdmissions)
     cotabplot(~ Admit + Gender | Dept, data = UCBAdmissions, panel = cotab_assoc)

     ucb <- cotab_coindep(UCBAdmissions, condvars = "Dept", type = "assoc", n = 5000, margins = c(3, 1, 1, 3))
     cotabplot(~ Admit + Gender | Dept, data = UCBAdmissions, panel = ucb)

