Sequential Loglinear Models for an N-way Table
This function takes an n-way contingency table and fits a series of sequential models to the 1-, 2-, ... n-way marginal tables, corresponding to a variety of types of loglinear models.
seq_loglm(x, type = c("joint", "conditional", "mutual", "markov", "saturated"), marginals = 1:nf, vorder = 1:nf, k = NULL, prefix = "model", fitted = TRUE, ...)
x |
a contingency table in array form, with optional category labels specified in the
dimnames(x) attribute,
or else a data.frame in frequency form, with the frequency variable named |
type |
type of sequential model to fit, a character string.
One of |
marginals |
which marginal sub-tables to fit? A vector of a (sub)set of the integers, |
vorder |
order of variables, a permutation of the integers |
k |
conditioning variable(s) for |
prefix |
prefix used to give names to the sequential models |
fitted |
argument passed to |
... |
other arguments, passed down |
Sequential marginal models for an n-way tables begin with the
model of equal-probability for the one-way margin
(equivalent to a chisq.test
) and add
successive variables one at a time in the order specified by
vorder
.
All model types give the same result for the two-way margin, namely the test of independence for the first two factors.
Sequential models of joint independence (type="joint"
)
have a particularly simple interpretation, because they
decompose the likelihood ratio test for the model of
mutual independence in the full n-way table, and hence
account for "total" association in terms of portions attributable
to the conditional probabilities of each new variable,
given all prior variables.
An object of class "loglmlist"
, each of which is a class "loglm"
object
Michael Friendly
These functions were inspired by the original SAS implementation of mosaic displays, described in the User's Guide, http://www.datavis.ca/mosaics/mosaics.pdf
loglin-utilities
for descriptions of sequential models,
conditional
,
joint
,
mutual
, ...
data(Titanic, package="datasets") # variables are in the order Class, Sex, Age, Survived tt <- seq_loglm(Titanic)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.