## S3 method for class 'default': mosaicplot(x, main = deparse(substitute(x)), sub = NULL, xlab = NULL, ylab = NULL, sort = NULL, off = NULL, dir = NULL, color = FALSE, shade = !(is.null(residuals) && is.null(margin)), margin = NULL, cex.axis = 0.66, las = par("las"), clegend = TRUE, type = c("pearson", "deviance", "FT"), residuals = NULL, ...) ## S3 method for class 'formula': mosaicplot(formula, data = NULL, \dots, main = deparse(substitute(data)), subset)
dimnames(x)attribute. The table is best created by the
names(dimnames(X))(i.e., the name of the first and second variable in
"v"for vertical and
"h"for horizontal) for each level of the mosaic, one direction for each dimension of the contingency table. The default consists of alternating directions, beginning
FALSE. The default
color=FALSEgives empty boxes with no shading.
loglm. By default, an independence model is fitted. See
"pearson"(giving components of Pearson's $\chi^2$),
"deviance"(giving components of the likelihood ratio $\chi^2$), or
y ~ x.
formulashould be taken.
mosaicplot.default) and a formula interface (
Extended mosaic displays show the standardized residuals of a loglinear model of the counts from by the color and outline of the mosaic's tiles. (Standardized residuals are often referred to a standard normal distribution.) Negative residuals are drawn in shaded of red and with broken outlines; positive ones are drawn in blue with solid outlines.
For the formula method, if
data is an object inheriting from
"ftable", or an array with more than
2 dimensions, it is taken as a contingency table, and hence all
entries should be nonnegative. In this case, the left-hand side of
formula should be empty, and the variables on the right-hand
side should be taken from the names of the dimnames attribute of the
contingency table. A marginal table of these variables is computed,
and a mosaic of this table is produced.
data should be a data frame or matrix, list or
environment containing the variables to be cross-tabulated. In this
case, after possibly selecting a subset of the data as specified by
subset argument, a contingency table is computed from the
variables given in
formula, and a mosaic is produced from
See Emerson (1998) for more information and a case study with television viewer data from Nielsen Media Research.
Emerson, J. W. (1998) Mosaic displays in S-PLUS: a general implementation and a case study. Statistical Computing and Graphics Newsletter (ASA), 9, 1, 17--23.
Friendly, M. (1994) Mosaic displays for multi-way contingency tables. Journal of the American Statistical Association, 89, 190--200.
The home page of Michael Friendly
data(Titanic) mosaicplot(Titanic, main = "Survival on the Titanic", color = TRUE) ## Formula interface for tabulated data: mosaicplot(~ Sex + Age + Survived, data = Titanic, color = TRUE) data(HairEyeColor) mosaicplot(HairEyeColor, shade = TRUE) ## Independence model of hair and eye color and sex. Indicates that ## there are significantly more blue eyed blond females than expected ## in the case of independence (and too few brown eyed blond females). mosaicplot(HairEyeColor, shade = TRUE, margin = list(c(1,2), 3)) ## Model of joint independence of sex from hair and eye color. Males ## are underrepresented among people with brown hair and eyes, and are ## overrepresented among people with brown hair and blue eyes, but not ## ``significantly''. ## Formula interface for raw data: visualize crosstabulation of numbers ## of gears and carburettors in Motor Trend car data. data(mtcars) mosaicplot(~ gear + carb, data = mtcars, color = TRUE) mosaicplot(~ gear + carb, data = mtcars, color = 2:3)# color recycling