link[MASS]{loglm}
model)
using the rgl-package
.
Generalizing the 2D mosaic plot, this begins
with a given 3D shape
(a unit cube), and successively sub-divides it along the X, Y, Z dimensions
according to the table margins, generating a nested set of 3D tiles.
The volume of the resulting tiles
is therefore proportional to the frequency represented in the
table cells.
Residuals from a given loglinear model are then used to color or shade each of the tiles.
This is a developing implementation. The arguments and details are subject to change.mosaic3d(x, ...)
## S3 method for class 'loglm':
mosaic3d(x, type = c("observed", "expected"), residuals_type = c("pearson", "deviance"), ...)
## S3 method for class 'default':
mosaic3d(x, expected = NULL, residuals = NULL,
type = c("observed", "expected"), residuals_type = NULL,
shape = cube3d(alpha = alpha), alpha = 0.5,
spacing = 0.1, split_dir = 1:3, shading = shading_basic, zero_size=.05,
label_edge,
labeling_args = list(), newpage = TRUE, box=FALSE, ...)
link[MASS]{loglm}
model object. Alternatively,
a multidimensional array
or table
or structable
of frequencies in a contingency table.
In the present implex
, or alternatively
the corresponding loglinear model specification as used by link[stats]{loglin}
or link[MASS]{loglm}
x
(see details)."observed"
or the "expected"
frequencies in the table should be visualized by the volume of the 3D tiles.NULL
, residuals_type
must be one of
"pearson"
(default; giving components of Pearson's chi-sshape3d
object.
The default is a "unit cube" on (-1, +1), with transparency specified by
alpha
.1:3
or a character vector
composed of c("x", "y", "z")
, where split_dir[i]
specifies the
axis along which the tiles should be split for dimension i
of the
tabshading=shading_basic
is provided. This is roughly equivalent
to the use of the shade
argumenc("-", "+")
indicating whether the
labels for a given table dimension are to be written at the minima ("-"
)
or maxima ("+"
) of the other dimensions in the plot.
The default mosaic.default
or 3D functions.shape3d
objects used to draw the 3D mosaic,
with names corresponding to the concatenation of the level labels, separated
by ":".expected
argument.
For the loglm method, residuals and observed frequencies are calculated from the model
object.strucplot
,
mosaic
,
mosaicplot
loglin
,
loglm
for details on fitting loglinear models# 2 x 2 x 2
mosaic3d(Bartlett, box=TRUE)
# compare with expected frequencies under model of mutual independence
mosaic3d(Bartlett, type="expected", box=TRUE)
# 2 x 2 x 3
mosaic3d(Heart, box=TRUE)
# 2 x 2 x 2 x 3
# illustrates a 4D table
mosaic3d(Detergent)
# compare 2D and 3D mosaics
demo("mosaic-hec")
Run the code above in your browser using DataLab