vcd (version 0.1-3.5)

fourfoldplot: Fourfold Plots

Description

Creates an (extended) fourfold display of a 2 by 2 by $k$ contingency table on the current graphics device, allowing for the visual inspection of the association between two dichotomous variables in one or several populations (strata).

Usage

fourfoldplot(x, color = c("#99CCFF","#6699CC","#FF5050","#6060A0", "#FF0000", "#000080"),
             conf.level = 0.95, std = c("margins", "ind.max", "all.max"),
             margin = c(1, 2), space = 0.2, main = NULL,
             mfrow = NULL, mfcol = NULL, extended = TRUE, ticks = 0.2,
             p.adjust.method = p.adjust.methods)

Arguments

x
a 2 by 2 by $k$ contingency table in array form, or as a 2 by 2 matrix if $k$ is 1.
color
a vector of length 6 specifying the colors to use for the smaller and larger diagonals of each 2 by 2 table. The first pair is used for the standard (non-extended) plots, the other two for the extended version: the second/third pair is used fo
conf.level
confidence level used for the confidence rings on the odds ratios. Must be a single nonnegative number less than 1; if set to 0, confidence rings are suppressed.
std
a character string specifying how to standardize the table. Must be one of "margins", "ind.max", or "all.max", and can be abbreviated by the initial letter. If set to "margins", each 2 by 2 t
margin
a numeric vector with the margins to equate. Must be one of 1, 2, or c(1, 2) (the default), which corresponds to standardizing the row, column, or both margins in each 2 by 2 table. Only used if
space
the amount of space (as a fraction of the maximal radius of the quarter circles) used for the row and column lebals.
main
character string for the fourfold title.
mfrow
a numeric vector of the form c(nr, nc), indicating that the displays for the 2 by 2 tables should be arranged in an nr by nc layout, filled by rows.
mfcol
a numeric vector of the form c(nr, nc), indicating that the displays for the 2 by 2 tables should be arranged in an nr by nc layout, filled by columns.
extended
if TRUE, extended plots are plotted, i.e. colors are brighter for significant logoddsratios, and ticks are plotted for pies with positive logodds.
ticks
the length of the ticks. If set to 0, no ticks are plotted.
p.adjust.method
method to be used for p-value adjustments for multistratum-plots. The p-values are used for the ``visual'' significance tests of the oddsratios.

Details

The fourfold display is designed for the display of 2 by 2 by $k$ tables.

Following suitable standardization, the cell frequencies $f_{ij}$ of each 2 by 2 table are shown as a quarter circle whose radius is proportional to $\sqrt{f_{ij}}$ so that its area is proportional to the cell frequency. An association (odds ratio different from 1) between the binary row and column variables is indicated by the tendency of diagonally opposite cells in one direction to differ in size from those in the other direction; color is used to show this direction. Confidence rings for the odds ratio allow a visual test of the null of no association; the rings for adjacent quadrants overlap iff the observed counts are consistent with the null hypothesis.

Typically, the number $k$ corresponds to the number of levels of a stratifying variable, and it is of interest to see whether the association is homogeneous across strata. The fourfold display visualizes the pattern of association. Note that the confidence rings for the individual odds ratios are not adjusted for multiple testing.

References

M. Friendly (1994), A fourfold display for 2 by 2 by $k$ tables. Technical Report 217, York University, Psychology Department, http://www.math.yorku.ca/SCS/Papers/4fold/4fold.ps.gz.

M. Friendly (2000), Visualizing Categorical Data. SAS Institute, Cary, NC.

See Also

mosaicplot

Examples

Run this code
data(UCBAdmissions)
## Use the Berkeley admission data as in Friendly (1995).
x <- aperm(UCBAdmissions, c(2, 1, 3))
dimnames(x)[[2]] <- c("Yes", "No")
names(dimnames(x)) <- c("Sex", "Admit?", "Department")
ftable(x)

## Fourfold display of data aggregated over departments, with
## frequencies standardized to equate the margins for admission
## and sex.
## Figure 1 in Friendly (1994).
fourfoldplot(margin.table(x, c(1, 2)))

## Fourfold display of x, with frequencies in each table
## standardized to equate the margins for admission and sex.
## Figure 2 in Friendly (1994).
fourfoldplot(x)

## Fourfold display of x, with frequencies in each table
## standardized to equate the margins for admission. but not
## for sex.
## Figure 3 in Friendly (1994).
fourfoldplot(x, margin = 2)

Run the code above in your browser using DataLab