Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

struc_assoc

Core-generating Function for Association Plots


Description

Core-generating function for strucplot returning a function producing association plots.

Usage

struc_assoc(compress = TRUE, xlim = NULL, ylim = NULL,
  yspace = unit(0.5, "lines"), xscale = 0.9, gp_axis = gpar(lty = 3))

Arguments

compress

logical; if FALSE, the space between the rows (columns) are chosen such that the total heights (widths) of the rows (column) are all equal. If TRUE, the space between the rows and columns is fixed and hence the plot is more “compressed”.

xlim

either a 2 x k matrix of doubles, k the number of total columns of the plot, or a recycled vector from which such a matrix will be constructed. The columns of xlim correspond to the columns of the association plot, the rows describe the column ranges (minimums in the first row, maximums in the second row). If xlim is NULL, the ranges are determined from the residuals according to compress (if TRUE: widest range from each column, if FALSE: from the whole association plot matrix).

ylim

either a 2 x k matrix of doubles, k the number of total rows of the plot, or a recycled vector from which such a matrix will be constructed. The columns of ylim correspond to the rows of the association plot, the rows describe the column ranges (minimums in the first row, maximums in the second row). If ylim is NULL, the ranges are determined from the residuals according to compress (if TRUE: widest range from each row, if FALSE: from the whole association plot matrix).

xscale

scale factor resizing the tile's width, thus adding additional space between the tiles.

yspace

object of class "unit" specifying additional space separating the rows.

gp_axis

object of class "gpar" specifying the visual aspects of the tiles' baseline.

Details

This function is usually called by strucplot (typically when called by assoc) and returns a function used by strucplot to produce association plots.

Value

A function with arguments:

residuals

table of residuals.

observed

not used by struc_assoc.

expected

table of expected frequencies.

spacing

object of class "unit" specifying the space between the tiles.

gp

list of gpar objects used for the drawing the tiles.

split_vertical

vector of logicals indicating, for each dimension of the table, the split direction.

Author(s)

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://datavis.ca/papers/sugi/sugi17.pdf

Meyer, D., Zeileis, A., and Hornik, K. (2006), The strucplot framework: Visualizing multi-way contingency tables with vcd. Journal of Statistical Software, 17(3), 1-48. doi: 10.18637/jss.v017.i03 and available as vignette("strucplot").

See Also

Examples

## UCB Admissions
data("UCBAdmissions")
ucb <- aperm(UCBAdmissions)

## association plot for conditional independence
strucplot(ucb, expected = ~ Dept * (Admit + Gender),
  core = struc_assoc(ylim = c(-4, 4)), labeling_args = list(abbreviate = c(Admit = 3)))

vcd

Visualizing Categorical Data

v1.4-10
GPL-2
Authors
David Meyer [aut, cre], Achim Zeileis [aut] (<https://orcid.org/0000-0003-0918-3766>), Kurt Hornik [aut], Florian Gerber [ctb], Michael Friendly [ctb]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.