assocplot              package:graphics              R Documentation

_A_s_s_o_c_i_a_t_i_o_n _P_l_o_t_s

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

     Produce a Cohen-Friendly association plot indicating deviations
     from independence of rows and columns in a 2-dimensional
     contingency table.

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

     assocplot(x, col = c("black", "red"), space = 0.3,
               main = NULL, xlab = NULL, ylab = NULL)

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

       x: a two-dimensional contingency table in matrix form.

     col: a character vector of length two giving the colors used for
          drawing positive and negative Pearson residuals,
          respectively.

   space: the amount of space (as a fraction of the average rectangle
          width and height) left between each rectangle.

    main: overall title for the plot.

    xlab: a label for the x axis.  Defaults to the name of the row
          variable in 'x' if non-'NULL'.

    ylab: a label for the y axis.  Defaults to the column names of the
          column variable in 'x' if non-'NULL'.

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

     For a two-way contingency table, the signed contribution to
     Pearson's chi^2 for cell i, j is d_{ij} = (f_{ij} - e_{ij}) /
     sqrt(e_{ij}), where f_{ij} and e_{ij} are the observed and
     expected counts corresponding to the cell.  In the Cohen-Friendly
     association plot, each cell is represented by a rectangle that has
     (signed) height proportional to d_{ij} and width proportional to
     sqrt(e_{ij}), so that the area of the box is proportional to the
     difference in observed and expected frequencies. The rectangles in
     each row are positioned relative to a baseline indicating
     independence (d_{ij} = 0).  If the observed frequency of a cell is
     greater than the expected one, the box rises above the baseline
     and is shaded in the color specified by the first element of
     'col', which defaults to black; otherwise, the box falls below the
     baseline and is shaded in the color specified by the second
     element of 'col', which defaults to red.

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

     Cohen, A. (1980), On the graphical display of the significant
     components in a two-way contingency table. _Communications in
     Statistics-Theory and Methods_, *A9*, 1025-1041.

     Friendly, M. (1992), Graphical methods for categorical data. _SAS
     User Group International Conference Proceedings_, *17*, 190-200.
     <URL: http://www.math.yorku.ca/SCS/sugi/sugi17-paper.html>

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

     'mosaicplot'; 'chisq.test'.

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

     ## Aggregate over sex:
     x <- margin.table(HairEyeColor, c(1, 2))
     x
     assocplot(x, main = "Relation between hair and eye color")

