| 42333 |
ripley |
1 |
% File src/library/graphics/man/assocplot.Rd
|
|
|
2 |
% Part of the R package, http://www.R-project.org
|
| 59039 |
ripley |
3 |
% Copyright 1995-2007 R Core Team
|
| 42333 |
ripley |
4 |
% Distributed under GPL 2 or later
|
|
|
5 |
|
| 57939 |
hornik |
6 |
\newcommand{\CRANpkg}{\href{http://CRAN.R-project.org/package=#1}{\pkg{#1}}}
|
|
|
7 |
|
| 27442 |
ripley |
8 |
\name{assocplot}
|
| 56186 |
murdoch |
9 |
\alias{assocplot}
|
| 50971 |
ripley |
10 |
\encoding{UTF-8}
|
| 27442 |
ripley |
11 |
\title{Association Plots}
|
|
|
12 |
\description{
|
|
|
13 |
Produce a Cohen-Friendly association plot indicating deviations from
|
|
|
14 |
independence of rows and columns in a 2-dimensional contingency
|
|
|
15 |
table.
|
|
|
16 |
}
|
|
|
17 |
\usage{
|
|
|
18 |
assocplot(x, col = c("black", "red"), space = 0.3,
|
|
|
19 |
main = NULL, xlab = NULL, ylab = NULL)
|
|
|
20 |
}
|
|
|
21 |
\arguments{
|
|
|
22 |
\item{x}{a two-dimensional contingency table in matrix form.}
|
|
|
23 |
\item{col}{a character vector of length two giving the colors used for
|
|
|
24 |
drawing positive and negative Pearson residuals, respectively.}
|
|
|
25 |
\item{space}{the amount of space (as a fraction of the average
|
| 27625 |
ripley |
26 |
rectangle width and height) left between each rectangle.}
|
| 27442 |
ripley |
27 |
\item{main}{overall title for the plot.}
|
| 36139 |
ripley |
28 |
\item{xlab}{a label for the x axis. Defaults to the name (if any) of
|
|
|
29 |
the row dimension in \code{x}.}
|
|
|
30 |
\item{ylab}{a label for the y axis. Defaults to the name (if any) of
|
|
|
31 |
the column dimension in \code{x}.}
|
| 27442 |
ripley |
32 |
}
|
|
|
33 |
\details{
|
|
|
34 |
For a two-way contingency table, the signed contribution to Pearson's
|
|
|
35 |
\eqn{\chi^2}{chi^2} for cell \eqn{i, j} is \eqn{d_{ij} = (f_{ij} -
|
|
|
36 |
e_{ij}) / \sqrt{e_{ij}}}{d_{ij} = (f_{ij} - e_{ij}) / sqrt(e_{ij})},
|
|
|
37 |
where \eqn{f_{ij}} and \eqn{e_{ij}} are the observed and expected
|
|
|
38 |
counts corresponding to the cell. In the Cohen-Friendly association
|
|
|
39 |
plot, each cell is represented by a rectangle that has (signed) height
|
|
|
40 |
proportional to \eqn{d_{ij}} and width proportional to
|
|
|
41 |
\eqn{\sqrt{e_{ij}}}{sqrt(e_{ij})}, so that the area of the box is
|
|
|
42 |
proportional to the difference in observed and expected frequencies.
|
|
|
43 |
The rectangles in each row are positioned relative to a baseline
|
|
|
44 |
indicating independence (\eqn{d_{ij} = 0}). If the observed frequency
|
|
|
45 |
of a cell is greater than the expected one, the box rises above the
|
|
|
46 |
baseline and is shaded in the color specified by the first element of
|
|
|
47 |
\code{col}, which defaults to black; otherwise, the box falls below
|
|
|
48 |
the baseline and is shaded in the color specified by the second
|
|
|
49 |
element of \code{col}, which defaults to red.
|
| 37294 |
hornik |
50 |
|
|
|
51 |
A more flexible and extensible implementation of association plots
|
|
|
52 |
written in the grid graphics system is provided in the function
|
| 57939 |
hornik |
53 |
\code{\link[vcd]{assoc}} in the contributed package \CRANpkg{vcd}
|
|
|
54 |
(Meyer, Zeileis and Hornik, 2005).
|
| 27442 |
ripley |
55 |
}
|
|
|
56 |
\seealso{
|
| 37294 |
hornik |
57 |
\code{\link{mosaicplot}}, \code{\link{chisq.test}}.
|
| 27442 |
ripley |
58 |
}
|
|
|
59 |
\references{
|
|
|
60 |
Cohen, A. (1980),
|
|
|
61 |
On the graphical display of the significant components in a two-way
|
|
|
62 |
contingency table.
|
|
|
63 |
\emph{Communications in Statistics---Theory and Methods}, \bold{A9},
|
|
|
64 |
1025--1041.
|
|
|
65 |
|
|
|
66 |
Friendly, M. (1992),
|
|
|
67 |
Graphical methods for categorical data.
|
|
|
68 |
\emph{SAS User Group International Conference Proceedings}, \bold{17},
|
|
|
69 |
190--200.
|
|
|
70 |
\url{http://www.math.yorku.ca/SCS/sugi/sugi17-paper.html}
|
| 37294 |
hornik |
71 |
|
|
|
72 |
Meyer, D., Zeileis, A., and Hornik, K. (2005)
|
|
|
73 |
The strucplot framework: Visualizing multi-way contingency tables with vcd.
|
| 61433 |
ripley |
74 |
\emph{Report 22}, Department of Statistics and Mathematics,
|
| 50971 |
ripley |
75 |
\enc{Wirtschaftsuniversität}{Wirtschaftsuniversitaet} Wien, Research Report Series.
|
| 55356 |
ripley |
76 |
\url{http://epub.wu.ac.at/dyn/openURL?id=oai:epub.wu-wien.ac.at:epub-wu-01_8a1}
|
| 27442 |
ripley |
77 |
}
|
|
|
78 |
\examples{
|
|
|
79 |
## Aggregate over sex:
|
|
|
80 |
x <- margin.table(HairEyeColor, c(1, 2))
|
|
|
81 |
x
|
|
|
82 |
assocplot(x, main = "Relation between hair and eye color")
|
|
|
83 |
}
|
|
|
84 |
\keyword{hplot}
|