Association plots have been suggested by Cohen (1980) and extended
by Friendly (1992) and provide a means for visualizing the residuals
of an independence model for a contingency table. assoc
is a generic function and currently has a default method and a
formula interface. Both are high-level interfaces to the
strucplot
function, and produce (extended) association
plots. Most of the functionality is described there, such as
specification of the independence model, labeling, legend, spacing,
shading, and other graphical parameters.
For a contingency table, the signed contribution
to Pearson's $\chi^2$ for cell ${ij\ldots k}$ is
$$d_{ij\ldots k} = \frac{(f_{ij\ldots k} - e_{ij\ldots k})}{
\sqrt{e_{ij\ldots k}}}$$
where $f_{ij\ldots k}$ and $e_{ij\ldots
k}$
are the observed and expected counts corresponding to the cell. In
the association plot, each cell is represented by a
rectangle that has (signed) height proportional to $d_{ij\ldots
k}$
and width proportional to
$\sqrt{e_{ij\ldots k}}$,
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\ldots k} = 0$).
If the observed frequency of a cell is greater than the expected one,
the box rises above the baseline, and falls below otherwise.
Additionally, the residuals can be colored depending on a specified
shading scheme (see Meyer et al., 2003). Package vcd offers a range of
residual-based shadings (see the shadings help page). Some of
them allow, e.g., the visualization of test statistics.
Unlike the assocplot
function in the
graphics package, this function allows the visualization of
contingency tables with more than two dimensions. Similar to the
construction of flat tables (like objects of class "ftable"
or
"structable"
), the dimensions are folded into rows and columns.
The layout is very flexible: the specification of shading, labeling,
spacing, and legend is modularized (see strucplot
for
details).