ipairs()For a table with several variables, a first exploratory step is to
look at all the two-way margins. vcd::pairs.table() draws
them as a scatterplot matrix of mosaic plots. ipairs() is
its interactive counterpart:
Hair and eye colour are strongly associated: blond hair with blue eyes, black and brown hair with brown eyes. Sex is almost independent of both. Hovering Blond in the hair–eye panel shows where blond people are in the sex panels.
Pairwise displays only show marginal associations.
They can hide or create associations that vanish once the other
variables are taken into account, as
vignette("ucb-admissions") shows. Use
imosaic() with a model for the conditional view.
ifourfold()For a \(2 \times 2\) table the
association is summarized by the odds ratio \[\theta = \frac{n_{11}\, n_{22}}{n_{12}\,
n_{21}}.\] The fourfold display (Friendly, 1994) draws each cell
as a quarter circle with area proportional to its frequency. With the
default standardization (std = "margins") the table is
first rescaled so that both margins are equal. This
leaves \(\theta\) unchanged and removes
the effect of unequal margins. Under independence the four quarters then
form a circle. When \(\theta > 1\)
the diagonal quarters are larger than the off-diagonal ones; when \(\theta < 1\) they are smaller.
For a table rescaled to equal margins, with total 1, the diagonal cells are equal to \[a = \frac{1}{2}\,\frac{\sqrt{\theta}}{1 + \sqrt{\theta}},\] and the off-diagonal cells to \(\frac12 - a\). The confidence rings draw the same quarters for the two bounds of the confidence interval of \(\theta\), which is computed on the log scale with \(\mathrm{SE}(\log\hat\theta) = \sqrt{\sum 1/n_{ij}}\). If the rings of adjacent quarters overlap, the odds ratio is not significantly different from 1. The diagonal quarters are blue when \(\theta > 1\) and red when \(\theta < 1\), with darker shades when the interval excludes 1.
For a \(2 \times 2 \times k\) table there is one display per stratum. The widget adds:
"margins", each
stratum scaled to its largest cell, all strata scaled to the largest
cell overall), the confidence rings and the confidence level.The forest plot makes the paradox of
vignette("ucb-admissions") visible. In department A the
odds ratio of admission for men versus women is well below 1: women are
favoured. In the other departments it is close to 1. Woolf’s test
rejects homogeneity because of department A alone. The Mantel–Haenszel
common odds ratio is close to 1, while the odds ratio of the aggregated
table is about 1.84 in favour of men: