EVOLUTION-MANAGER
Edit File: assocplot.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Association Plots</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for assocplot {graphics}"><tr><td>assocplot {graphics}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Association Plots</h2> <h3>Description</h3> <p>Produce a Cohen-Friendly association plot indicating deviations from independence of rows and columns in a 2-dimensional contingency table. </p> <h3>Usage</h3> <pre> assocplot(x, col = c("black", "red"), space = 0.3, main = NULL, xlab = NULL, ylab = NULL) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>x</code></td> <td> <p>a two-dimensional contingency table in matrix form.</p> </td></tr> <tr valign="top"><td><code>col</code></td> <td> <p>a character vector of length two giving the colors used for drawing positive and negative Pearson residuals, respectively.</p> </td></tr> <tr valign="top"><td><code>space</code></td> <td> <p>the amount of space (as a fraction of the average rectangle width and height) left between each rectangle.</p> </td></tr> <tr valign="top"><td><code>main</code></td> <td> <p>overall title for the plot.</p> </td></tr> <tr valign="top"><td><code>xlab</code></td> <td> <p>a label for the x axis. Defaults to the name (if any) of the row dimension in <code>x</code>.</p> </td></tr> <tr valign="top"><td><code>ylab</code></td> <td> <p>a label for the y axis. Defaults to the name (if any) of the column dimension in <code>x</code>.</p> </td></tr> </table> <h3>Details</h3> <p>For a two-way contingency table, the signed contribution to Pearson's <i>chi^2</i> for cell <i>i, j</i> is <i>d_{ij} = (f_{ij} - e_{ij}) / sqrt(e_{ij})</i>, where <i>f_{ij}</i> and <i>e_{ij}</i> 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 <i>d_{ij}</i> and width proportional to <i>sqrt(e_{ij})</i>, 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 (<i>d_{ij} = 0</i>). 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 <code>col</code>, which defaults to black; otherwise, the box falls below the baseline and is shaded in the color specified by the second element of <code>col</code>, which defaults to red. </p> <p>A more flexible and extensible implementation of association plots written in the grid graphics system is provided in the function <code><a href="../../vcd/html/assoc.html">assoc</a></code> in the contributed package <a href="https://CRAN.R-project.org/package=vcd"><span class="pkg">vcd</span></a> (Meyer, Zeileis and Hornik, 2006). </p> <h3>References</h3> <p>Cohen, A. (1980), On the graphical display of the significant components in a two-way contingency table. <em>Communications in Statistics—Theory and Methods</em>, <b>9</b>, 1025–1041. doi: <a href="https://doi.org/10.1080/03610928008827940">10.1080/03610928008827940</a>. </p> <p>Friendly, M. (1992), Graphical methods for categorical data. <em>SAS User Group International Conference Proceedings</em>, <b>17</b>, 190–200. <a href="http://www.math.yorku.ca/SCS/sugi/sugi17-paper.html">http://www.math.yorku.ca/SCS/sugi/sugi17-paper.html</a> </p> <p>Meyer, D., Zeileis, A., and Hornik, K. (2006) The strucplot Framework: Visualizing Multi-Way Contingency Tables with <span class="pkg">vcd</span>. <em>Journal of Statistical Software</em>, <b>17(3)</b>, 1–48. doi: <a href="https://doi.org/10.18637/jss.v017.i03">10.18637/jss.v017.i03</a>. </p> <h3>See Also</h3> <p><code><a href="mosaicplot.html">mosaicplot</a></code>, <code><a href="../../stats/html/chisq.test.html">chisq.test</a></code>. </p> <h3>Examples</h3> <pre> ## Aggregate over sex: x <- margin.table(HairEyeColor, c(1, 2)) x assocplot(x, main = "Relation between hair and eye color") </pre> <hr /><div style="text-align: center;">[Package <em>graphics</em> version 3.6.0 <a href="00Index.html">Index</a>]</div> </body></html>