Learn R Programming

GDAtools (version 1.7)

ggassoc_phiplot: Bar plot of phi measures of association of a crosstabulation

Description

For a cross-tabulation, plots the phi measures of association with bars of varying height, using ggplot2.

Usage

ggassoc_phiplot(data, mapping, measure="phi", max.asso=NULL,
sort="none", axes.labs=TRUE, ticks.labs=TRUE, text.size=3)

Arguments

data

dataset to use for plot

mapping

aesthetic being used. It must specify x and y.

measure

character. The measure for attractions: "phi" (default) for phi coefficients, "pem" for percentages of maximum deviation (PEM).

max.asso

numeric value, specifying the lower and upper limit of the scale for the color gradient filling the rectangles, i.e. for the measures of association. It corresponds to the maximum absolute value of association one wants to represent in the plot. If NULL (default), the limit is automatically adjusted to the data.

sort

character. If "both", rows and columns are sorted according to the first factor of a correspondence analysis of the contingency table. If "x", only rows are sorted. If "y", only columns are sorted. If "none" (default), no sorting is done.

axes.labs

Whether to display the labels of the axes, i.e. the names of x and y. Default is TRUE.

ticks.labs

Whether to display the labels of the categories of x and y. Default is TRUE.

text.size

Size of the association measure. If NULL, the text is not added to the plot.

Value

a ggplot object

Details

The phi measure of association measures how much each combination of categories of x and y is over/under-represented. The bars vary in width according to the number of observations in the categories of the x variables. They vary in height according to the phi measure of association. Bars are black if phi is positive and white if phi is negative.

Cramer's V measure of global association between x and y is displayed in upper-left corner of the plot.

This function can be used as a high-level plot with ggduo and ggpairs functions of the GGally package.

References

Cibois Philippe, 2004, Les <U+00E9>carts <U+00E0> l'ind<U+00E9>pendance. Techniques simples pour analyser des donn<U+00E9>es d'enqu<U+00EA>tes, Collection "M<U+00E9>thodes quantitatives pour les sciences sociales"

See Also

assoc.twocat, phi.table, catdesc, assoc.yx, darma, ggassoc_crosstab, ggpairs

Examples

Run this code
# NOT RUN {
data(Taste)
ggassoc_phiplot(data=Taste, mapping=ggplot2::aes(x=Age, y=Classical))
# }

Run the code above in your browser using DataLab