vcd (version 0.9-0)

pairs.table: Pairs Plot for Contingency Tables

Description

Produces a matrix of strucplots.

Usage

## S3 method for class 'table':
pairs(x, upper_panel = pairs_mosaic, upper_panel_args = list(),
  lower_panel = pairs_mosaic, lower_panel_args = list(),
  diag_panel = pairs_barplot, diag_panel_args = list(),
  main = NULL, title_gp = gpar(fontsize = 20), space = 0.1,
  newpage = TRUE, ...)

Arguments

x
a contingency table in array form, with optional category labels specified in the dimnames(x) attribute.
upper_panel
function for the upper triangle of the matrix, or corresponding generating function.
upper_panel_args
list of arguments for the generating function, if specified.
lower_panel
function for the lower triangle of the matrix, or corresponding generating function.
lower_panel_args
list of arguments for the panel-generating function, if specified.
diag_panel
function for the diagonal of the matrix, or corresponding generating function.
diag_panel_args
list of arguments for the generating function, if specified.
main
character string specifying the main title.
title_gp
object of class "gpar" used for the title.
space
double specifying the distance between the cells.
newpage
logical controlling whether a new grid page should be created.
...
currently not used.

Details

This is a pairs method for objects inheriting from class "table". It plots a matrix of pairwise mosaic plots. Four independence types are distinguished: "pairwise", "total", "conditional" and "joint". The pairwise mosaic matrix shows bivariate marginal relations, collapsed over all other variables. The total independence mosaic matrix shows mosaic plots for mutual independence, i.e., for marginal and conditional independence among all pairs of variables. The conditional independence mosaic matrix shows mosaic plots for marginal independence given all other variables. The joint independence mosaic matrix shows mosaic plots for joint independence of all pairs of variables from the others.

This method uses panel functions called for each cell of the matrix which can be different for upper matrix, lower matrix, and diagonal cells. Correspondingly, for each panel parameter foo (= upper, lower, or diag), pairs.table takes two arguments: foo_panel and foo_panel_args, which can be used to specify the parameters as follows:

  1. Passing a suitable panel function tofoo_panelwhich subsequently is called for each cell with the corresponding coordinates.
  2. Passing a correspondinggenerating function(of class"panel_generator") tofoo_panel, along with parameters passed tofoo_panel_args, that generates such a function.
Hence, the second approach is equivalent to the first if foo_panel(foo_panel_args) is passed to foo_panel.

References

Cohen, A. (1980), On the graphical display of the significant components in a two-way contingency table. Communications in Statistics---Theory and Methods, A9, 1025--1041.

Friendly, M. (1992), Graphical methods for categorical data. SAS User Group International Conference Proceedings, 17, 190--200. http://www.math.yorku.ca/SCS/sugi/sugi17-paper.html

See Also

pairs_mosaic, pairs_assoc, pairs_text, pairs_barplot, assoc

Examples

Run this code
data(UCBAdmissions)
data(PreSex)

pairs(PreSex)
pairs(UCBAdmissions)
pairs(UCBAdmissions, upper_panel_args = list(shade = FALSE))
pairs(UCBAdmissions, lower_panel = pairs_mosaic(type = "conditional"))
pairs(UCBAdmissions, diag_panel = pairs_text)
pairs(UCBAdmissions, upper_panel = pairs_assoc)

Run the code above in your browser using DataCamp Workspace